user1554336
user1554336

Reputation:

Issues in image transformation in j2me

I'm developing a game in j2me. I don't need sprites for this game, I'm painting images directly. The method which I'm following to flip an image is as follows. But on device,it is shown as in fig 1.1. How to resolve this problem.? Please help.

Image.createImage(source,0, 0, source.getWidth(), source.getHeight(), Sprite.TRANS_ROT180);

fig 1.0 : Before flipping car image

enter image description here

fig 1.1 : After flipping car image

enter image description here

The background is white in color when flipped as seen. Is there any other method to flip an image?

Car width is 60x62 with transparent pixels..but wen the same image is flipped,transparency is gone with white background.

Upvotes: 3

Views: 288

Answers (1)

gnat
gnat

Reputation: 6229

According to API documentation, this version of Image.createImage is expected to preserve transparency if the original image is immutable:

For immutable source images, transparency information, if any, is copied to the new image unchanged.

To find out what could cause the loss of transparency at flipped image, check whether 1) source image is immutable and 2) whether pixels at source image are transparent indeed (alpha channel value is 0), as explained in API docs for Image class, Alpha Processing section:

Every pixel within a mutable image is always fully opaque. Immutable images may contain a combination of fully opaque pixels..., fully transparent pixels (alpha = 0), and semitransparent pixels...

Implementations must support storage, processing, and rendering of fully opaque pixels and fully transparent pixels in immutable images. When creating an image from source data (whether from a PNG file or from an array of ARGB data), a fully opaque pixel in the source data must always result in a fully opaque pixel in the new image, and a fully transparent pixel in the source data must always result in a fully transparent pixel in the new image...

Upvotes: 3

Related Questions