Skip to main content
gamedev.net
🔒 Locked

[java] tranparent images/graphics

Started by thuned Mar 1, 2001 at 6:51 PM 1 replies 300+ views
Original Post
thuned
thuned
if i have images and graphics declared and intialized like Image BGC; Graphics BGG; BGC = createImage(600,600); BGG = BGC.getGraphics(); then i proceed to draw stuff on BGG. how do i make it so the stuff i didn''t draw over is transparent? thuned life is unfair, take advantage of it. UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
sahmed
sahmed
I''ve done something like this:

int[] pixel = new int[20 * 20];

int red = 50, green = 50, blue = 50, alpha = 130;

for (int i = 0; i++ < pixel.length
pixel = alpha << 24 | red << 16 | green << 8 | blue;


createImage(new MemoryImageSource(w, h, pixel, 0, w);


Basically it sets the pixels manually to the rgb and alpha value. Alpha value controls transparency from 0 being totally transparent to 255 for opaque.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.