Archived

This topic is now archived and is closed to further replies.

Smoo

[java] MemoryImageSource

Recommended Posts

Smoo    122
I know we talked about this in another thread (More Graphic Stuff) but I am still having troubles with this topic. I asked before how to understand integers with the ARGB. I understand this but I''m getting a recurring problem when I attempt to even do the slightest manipulation with it. Every time i turn out an image that has gone through a change it basically shifts it.. okay that was badly explained. It does an effect like Johnny Cage''s shadow movements or the shadow movements in StarCraft done by High Templar... I hope that clears it us a bit. If you didn''t get what I meant by that, it takes some of the pixels and shifts them to the right giving an illusion of the pic being to the right but it takes other and shifts them to the left so I turn out with a pixels not being in the right place. Well, here''s the best way of showing you what my code is: for (int y = 0; y < 240; y++) for (int x = 0; x < 320; x++) { int alpha = (cigarAr[index] >> 24) & 0xff; int red = (cigarAr[index] >> 16) & 0xff; int green = (cigarAr[index] >> 8) & 0xff; int blue = (cigarAr[index]) & 0xff; alpha = 200 << 24; cigarAr[index] = alpha | (red & 0x00ff0000) | (green & 0x0000ff00)| (blue & 0xff); index++; } newCigar = createImage(mic2); This code somehow screws up the image because the only other code that does something is the pixelGrabber. Any suggestions would be greatly appreciated. Smoo

Share this post


Link to post
Share on other sites
ao    122
This should help, take this line:

cigarAr[index] = alpha | (red & 0x00ff0000) | (green & 0x0000ff00)| (blue & 0xff);

and change it to this:

cigarAr[index] = alpha | ( red << 16 ) | ( green << 8 ) | b;

if you do decide to take that line out that says:

alpha = 200 << 24;

Then you'll need to do the shifting for the alpha in the cigarAr[index] = ... equation.

ao



Edited by - ao on October 4, 2000 1:51:36 AM

Share this post


Link to post
Share on other sites
Smoo    122
Well I tried it you''re way and basically what it does is remove a lot of code that I needed before so it''s helpful in that respect.

I did find out my problem though and it was partly (well mostly) on my ignorance on how MemoryImageSource actually works

i had:
mic2 = new MemoryImageSource(320, 240, cigarAr, 0, 240);
whereas i needed:
mic2 = new MemoryImageSource(320, 240, cigarAr, 0, 320);

one word for myself: duh!

Well, I''m happy that it works now... mostly
This brings up another topic along these lines. The image that I am getting seems a bit grainy. The transparency works on most areas but alot more on others.

If you understand what I''m talking about, any pointers on how to clear up the image would be really appreciated.

Thanks,
Smoo

Share this post


Link to post
Share on other sites