diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-07 16:25:52 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-05-08 16:36:50 -0700 |
commit | ccd4c42d08b1f6b3fe88c68a6e6c1fc74b058de3 (patch) | |
tree | dbb40bbed0122e8d2b5dfb421c7b36b5ad775a58 /assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java | |
parent | 744109a2331c46902d5c978067fbebb1855763ee (diff) | |
download | sdk-ccd4c42d08b1f6b3fe88c68a6e6c1fc74b058de3.zip sdk-ccd4c42d08b1f6b3fe88c68a6e6c1fc74b058de3.tar.gz sdk-ccd4c42d08b1f6b3fe88c68a6e6c1fc74b058de3.tar.bz2 |
Asset Studio: Add no-background option, and support embedding
This changeset improves the asset studio wizard in two ways:
- First, it adds support for having no background shape (which the web
version has added)
- Second, it adds a "value holder" class which holds the current (as
well as initial) state of the various configuration parameters for
the icon generator. This allows the same code to be used to generate
icons programatically, and also allows reuse of the asset studio
wizard pages in different wizards and with custom initial state.
For example, the New Project wizard can now embed the asset studio
page and preconfigure it to generate launcher icons.
Change-Id: I9eac396325214af8309447083ff9dcb9e59645ab
Diffstat (limited to 'assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java')
-rw-r--r-- | assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java b/assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java index 4e0534d..b3e327b 100644 --- a/assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java +++ b/assetstudio/src/com/android/assetstudiolib/LauncherIconGenerator.java @@ -42,12 +42,17 @@ public class LauncherIconGenerator extends GraphicGenerator { density = launcherOptions.density.getResourceValue(); } String shape = launcherOptions.shape.id; - BufferedImage mBackImage = context.loadImageResource("/images/launcher_stencil/" + BufferedImage mBackImage = null; + BufferedImage mForeImage = null; + BufferedImage mMaskImage = null; + if (launcherOptions.shape != Shape.NONE) { + mBackImage = context.loadImageResource("/images/launcher_stencil/" + shape + "/" + density + "/back.png"); - BufferedImage mForeImage = context.loadImageResource("/images/launcher_stencil/" + mForeImage = context.loadImageResource("/images/launcher_stencil/" + shape + "/" + density + "/" + launcherOptions.style.id + ".png"); - BufferedImage mMaskImage = context.loadImageResource("/images/launcher_stencil/" + mMaskImage = context.loadImageResource("/images/launcher_stencil/" + shape + "/" + density + "/mask.png"); + } float scaleFactor = GraphicGenerator.getMdpiScaleFactor(launcherOptions.density); if (launcherOptions.isWebGraphic) { @@ -59,14 +64,18 @@ public class LauncherIconGenerator extends GraphicGenerator { BufferedImage outImage = Util.newArgbBufferedImage(imageRect.width, imageRect.height); Graphics2D g = (Graphics2D) outImage.getGraphics(); - g.drawImage(mBackImage, 0, 0, null); + if (mBackImage != null) { + g.drawImage(mBackImage, 0, 0, null); + } BufferedImage tempImage = Util.newArgbBufferedImage(imageRect.width, imageRect.height); Graphics2D g2 = (Graphics2D) tempImage.getGraphics(); - g2.drawImage(mMaskImage, 0, 0, null); - g2.setComposite(AlphaComposite.SrcAtop); - g2.setPaint(new Color(launcherOptions.backgroundColor)); - g2.fillRect(0, 0, imageRect.width, imageRect.height); + if (mMaskImage != null) { + g2.drawImage(mMaskImage, 0, 0, null); + g2.setComposite(AlphaComposite.SrcAtop); + g2.setPaint(new Color(launcherOptions.backgroundColor)); + g2.fillRect(0, 0, imageRect.width, imageRect.height); + } if (launcherOptions.crop) { Util.drawCenterCrop(g2, launcherOptions.sourceImage, targetRect); @@ -75,7 +84,9 @@ public class LauncherIconGenerator extends GraphicGenerator { } g.drawImage(tempImage, 0, 0, null); - g.drawImage(mForeImage, 0, 0, null); + if (mForeImage != null) { + g.drawImage(mForeImage, 0, 0, null); + } g.dispose(); g2.dispose(); |