Skip to content

Instantly share code, notes, and snippets.

@codenameone
Created February 28, 2016 12:53
Show Gist options
  • Save codenameone/2515be7528ef3e402ec0 to your computer and use it in GitHub Desktop.
Save codenameone/2515be7528ef3e402ec0 to your computer and use it in GitHub Desktop.
Demonstrates the URLImage mask adapter usage in Codename One. This mask adapter will turn all downloaded images into circular images
Image roundMask = Image.createImage(placeholder.getWidth(), placeholder.getHeight(), 0xff000000);
Graphics gr = roundMask.getGraphics();
gr.setColor(0xffffff);
gr.fillArc(0, 0, placeholder.getWidth(), placeholder.getHeight(), 0, 360);
URLImage.ImageAdapter ada = URLImage.createMaskAdapter(roundMask);
Image i = URLImage.createToStorage(placeholder, "fileNameInStorage", "http://xxx/myurl.jpg", ada);
@codenameone
Copy link
Author

Sample usage of URLImage.

From the Codename One project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment