Results 1 to 3 of 3
Thread: Transparency issues..
- 09-25-2012, 12:53 AM #1
Member
- Join Date
- Sep 2012
- Posts
- 34
- Rep Power
- 0
Transparency issues..
hello, i'm trying to eliminate the background of a sprite, i have found several forum talks about it, the problem is that
i manage to set the alpha of the color i want to make transparent to zero, but when i draw the image, it has a gray background instead of what color it used to be. please help.
code:
Java Code:public void cleanImage(BufferedImage target,int r,int g,int b,int a) { int col = ((a << 24) | (r << 16) | (g << 8) | b); int trans = ((0 << 24) | (r << 16) | (g << 8) | b); int [] pixels = ((DataBufferInt)target.getRaster().getDataBuffer()).getData(); ColorModel cm = target.getColorModel(); SampleModel sm = target.getRaster().getSampleModel(); for (int i = 0;i<pixels.length;i++) if (pixels[i] == col) pixels[i] = trans;//-1118482; DataBuffer db = new DataBufferInt(pixels,target.getHeight()*target.getWidth()); WritableRaster wr = Raster.createWritableRaster(sm,db,null); target = new BufferedImage(cm, wr, false, null); }
-
- 09-25-2012, 10:08 AM #3
Member
- Join Date
- Sep 2012
- Posts
- 34
- Rep Power
- 0
Similar Threads
-
JTable Transparency
By Redefine12 in forum Java 2DReplies: 4Last Post: 04-17-2012, 09:24 AM -
Transparency
By zirbinator in forum Java 2DReplies: 7Last Post: 03-28-2012, 05:51 AM -
DrawImage with transparency ?
By mrhid6 in forum AWT / SwingReplies: 2Last Post: 10-01-2011, 11:58 PM -
Transparency problem
By Lacrim in forum Java AppletsReplies: 1Last Post: 07-27-2011, 01:34 PM -
ImageIcon Transparency
By Lingerz in forum New To JavaReplies: 2Last Post: 06-04-2010, 02:53 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks