Does Java ME support 0xAARRGGBB color format? 开发者_运维百科I mean can I change the opacity of an image by modifying the alpha value of pixels? I work with Graphics and Image classes.
This will undoubtedly vary between devices. Why not just try it and see?
Edit: OK so I guess you want to know actually how to do it. The method you will need is Image.getRGB()
-- as per the docs:
Obtains ARGB pixel data from the specified region of this image and stores it in the provided array of integers. Each pixel value is stored in 0xAARRGGBB format, where the high-order byte contains the alpha channel and the remaining bytes contain color components for red, green and blue, respectively. The alpha channel specifies the opacity of the pixel, where a value of 0x00 represents a pixel that is fully transparent and a value of 0xFF represents a fully opaque pixel.
Modify the pixels you want then use the data to create a new image using Image.createRGBImage()
.
Edit: The spec says that all devices should allow alpha manipulation.
One way to tell whether they do or not is to create a mutable image, get its graphics object, write some ARGB data to it, then read it back, and see if the alpha data is still present; if not then you can bet alpha transparency is not supported.
The methods I've linked to should be all you need to do this, the actual method I leave as an exercise ;)
精彩评论