Hi Christopher,
Thanks a lot for your feedback, I'm glad to see this code helps...
I looked at what Oliver provided to improve the speed, and it did not
work. I investigated and I found that I had to tweak the image I used
as a mask for it to work.
Oops... I had tested images with only transparent black & solid
white in them... Felt like the code worked, but it was by chance :
the only pixels considered transparent were those with zero ARGB
pixel value (zero alpha AND pure black color). Thanks for pointing
this out...
It would be good (...) that it takes care internally of this color
issue, so
that user code would not have to fiddle with it.
I changed RasterRangesUtils a bit : it now has an
outputOccupiedRanges method that outputs occupied pixels :
- in an image with alpha layer, occupied means "alpha not null".
- in an image without alpha layer, occupied means "not completely
black".
I also took a little more care in reusing the raster's backing array.
The updated code is still at the same location :
http://ochafik.free.fr/Java/src/jna/
It would be good to have this fast algorithm to be in the official
version
This matter has been mentioned once and Timothy pointed out that it
was better to keep the examples clean and simple. I proposed to
create a package com.sun.jna.awt for windowing-related stuff, but I
am unsure whether this is a good idea... Maybe it would be better to
create a separate jar jna-extras.jar with code samples that are
expected to be more complete and performant than simple examples.
Please tell me if this new code works for you (I did very little
testing), and... have fun !
Cheers