midp2 and transparency

hello all

I found this in the link below :

http://developers.sun.com/techtopics/mobility/midp/articles/gameapi/index.html

MIDP 1.0 makes developing games, including networked games, difficult in several ways:

# The Graphics class provides no support for any form of transparency, for using an image mask, or for defining a transparent color.

but I didn't found any way for applying transparency in midp 2.0.

is there any way?

[469 byte] By [etaa] at [2007-11-27 5:16:26]
# 1
hello I read that the midp 2.0 standard says that the png image transparency must be applied.but my emulator(j2me wtk 2.5) doesn't do that.what is the problem?
etaa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
maybe your code because mine works well!!!
suparenoa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
my code or my image ?!!!!!I don't know more than one kind of code.Image.createImage("/image.png");do you know any other code?
etaa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
what is your problem?on a black background, are you sure that your image is not transparent...
suparenoa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
You must use PNG transparency. I suspect the problem is with your image not your code.
jonathan.lea at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6

I built my image with photoshop.

my image is transparent. in it.

but for example in acd see it is not.

the file format is png

my problem is :

when I draw my transparent picture on a canvas, it isn't transparent.

I passed my canvas' graphics to a static method of another class to paint on it.

but there is no transparency.

you said that my code may be wrong.

can you explain how this could happen with a transparent image?

how can I draw it untransparen?

Message was edited by:

eta

etaa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
so the problem comes from the image !!! http://www.oreilly.com/catalog/pngdefg/chapter/ch04.html
suparenoa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8

thank you all

I found the problem.

It was just because my ImageResizer.

/**

* ImageResizer.java

* copied from the web!!!!

* http://developers.sun.com/techtopics/mobility/reference/techart

* /design_guidelines/image_resizing.html

*/

package mobile;

import javax.microedition.lcdui.Graphics;

import javax.microedition.lcdui.Image;

public class ImageResizer {

public ImageResizer() {

}

public static Image resizeImage(Image src, int newWidth, int newHeight) {

int srcWidth = src.getWidth();

int srcHeight = src.getHeight();

Image tmp = Image.createImage(newWidth, srcHeight);

Graphics g = tmp.getGraphics();

int ratio = (srcWidth << 16) / newWidth;

int pos = ratio/2;

//Horizontal Resize

for (int x = 0; x < newWidth; x++) {

g.setClip(x, 0, 1, srcHeight);

g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);

pos += ratio;

}

Image resizedImage = Image.createImage(newWidth, newHeight);

g = resizedImage.getGraphics();

ratio = (srcHeight << 16) / newHeight;

pos = ratio/2;

//Vertical resize

for (int y = 0; y < newHeight; y++) {

g.setClip(0, y, newWidth, 1);

g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);

pos += ratio;

}

return resizedImage;

}

}

in this line:

Image tmp = Image.createImage(newWidth, srcHeight);

do you have any good idea for the problem.(I have one bad my self)

etaa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 9

you can use this...

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Image.html#createRGBImage(int[],%20int,%20int,%20boolean)

(it is since MIDP 2.0, so if it's MIPD 1.0, it will not be possible!! i'm not sure but i think that MIDP 1.0 does not support transparency)

Message was edited by:

supareno

suparenoa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 10
thanksand excuse me againIs there any way to overwrite my image with the new resized image.Or I must resize them as initialization every time.I think I can do this using an rms. but if I can over write my Image it will be better.
etaa at 2007-7-12 10:39:04 > top of Java-index,Java Mobility Forums,Java ME Technologies...