Permalink
Browse files

Fixed ID duplication issue (why did I implement postCopy to duplicate…

… ID?). Improved (?) sprite transparency downgrading by replacing >50% transparent pixels with a hopefully unique "flamingo pink" rather than just opaquing their original color.

git-svn-id: https://lateralgm.svn.sourceforge.net/svnroot/lateralgm/LateralGM/trunk@554 8f422083-7f27-0410-bc82-93e204be8cd2
  • Loading branch information...
1 parent 9e5dfb3 commit f9aac4e5cd3183c4539e96e292e6f7a36195396a ismavatar committed Dec 11, 2011
Showing with 10 additions and 3 deletions.
  1. +9 −1 org/lateralgm/file/GmStreamEncoder.java
  2. +1 −2 org/lateralgm/resources/InstantiableResource.java
@@ -183,9 +183,17 @@ public void writeZlibImage(BufferedImage image) throws IOException
WritableRaster raster = cm.createCompatibleWritableRaster(image.getWidth(),image.getHeight());
int[] data = ((DataBufferInt) raster.getDataBuffer()).getData();
+ //color to replace fully transparent pixels with
+ //TODO: Replace with a user-selectable system
+ final int transparentReplacement = 0xF496A1; //0xF496A1 is "flamingo pink"
+ final int threshold = 0x80000000;
+
//assume the two buffers are the same size...
for (int i = 0; i < pixels.length; i++)
- data[i] = pixels[i] & 0x00FFFFFF; //forcibly drop alpha channel
+ if (pixels[i] < threshold)
+ data[i] = transparentReplacement;
+ else
+ data[i] = pixels[i] & 0x00FFFFFF; //forcibly drop alpha channel
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(new BufferedImage(cm,raster,false,null),"bmp",out); //$NON-NLS-1$
@@ -49,8 +49,7 @@ public int getId()
}
protected void postCopy(R dest)
- {
- dest.setId(getId());
+ { //default implementation is to do nothing
}
public abstract R makeInstance(ResourceReference<R> ref);

0 comments on commit f9aac4e

Please sign in to comment.