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]

# 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 >

# 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 >

# 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