MIDPã§ç»åã®æ¡å¤§ç¸®å°é¢æ°
æ¢ãã¦ãããã¾ãè¦ã¤ãããªãã®ã§ä½ã£ã¦ã¿ãã
/**
* æ¡å¤§ç¨é¢æ°
* Graphics g
* Image image æ¡å¤§ããç»å
* int dx, dy æç»å 座æ¨
* int scaled æ¡å¤§ç
* int sx, sy æç»å 座æ¨
* int width, height æç»å ãµã¤ãº
*/
private void drawScaledImage1(Graphics g, Image image, int dx, int dy, int scaled,
int sx, int sy, int width, int height)
{
int w = width * scaled;
int h = height * scaled;
int[] pixels = new int[width*height];
int[] scaled_pixels = new int[w*h];
image.getRGB(pixels, 0, width, sx, sy, width, height);
for(int y = 0; y < h; y++)
{
for(int x = 0; x < w; x++)
{
scaled_pixels[x+w*y] = pixels[(x/scaled)+width*(y/scaled)];
}
}
g.drawRGB(scaled_pixels, 0, w, dx, dy, w, h, false);
}
/**
* 縮å°ç¨é¢æ°
* Graphics g
* Image image 縮å°ããç»å
* int dx, dy æç»å 座æ¨
* int scaled 縮å°ç (2ã§2åã®1ã«ãªã)
* int sx, sy æç»å 座æ¨
* int width, height æç»å ãµã¤ãº
*/
private void drawScaledImage2(Graphics g, Image image, int dx, int dy, int scaled,
int sx, int sy, int width, int height)
{
int w = width / scaled;
int h = height / scaled;
int[] pixels = new int[width*height];
int[] scaled_pixels = new int[w*h];
image.getRGB(pixels, 0, width, sx, sy, width, height);
for(int y = 0; y < h; y++)
{
for(int x = 0; x < w; x++)
{
scaled_pixels[x+w*y] = pixels[(x*scaled)+width*(y*scaled)];
}
}
g.drawRGB(scaled_pixels, 0, w, dx, dy, w, h, false);
}
ã¾ã å®æãããªãã¨ããããã¾ã試ä½å
å®æåã¯ä»ã®ç¥èã§ã¯ç¡çããªããã
端ã¨ç«¯ãæãããã縦横ã®åçå²ãä»ãçãªãã¨ãããã¡ããããã¡ããããªãã¨ãããªããã ãããª
setFrameé¢æ°
public void setFrame(int sequenceIndex)ãã¬ã¼ã ã»ã·ã¼ã±ã³ã¹ä¸ã®ç¾å¨ã®ãã¬ã¼ã ãé¸æãã¾ãã
paint(Graphics) ã¡ã½ãããå¼ã°ããã¨ãã«ç¾å¨ã®ãã¬ã¼ã ãã¬ã³ããªã³ã°ããã¾ãã
æä¾ãããã¤ã³ããã¯ã¹ã¯ãå®éã®ãã¬ã¼ã ãã®ãã®ã®ã¤ã³ããã¯ã¹ã§ã¯ãªãããã¬ã¼ã ã»ã·ã¼ã±ã³ã¹ä¸ã®å¸æã®ã¨ã³ããªã示ãã¾ãã
ãã¬ã¼ã ã·ã¼ã±ã³ã¹ã®é ãè¦ãã°å³ã§åããã
MIDP2.0ãªãã¡ã¬ã³ã¹
http://godwood.allnet.ne.jp/vioret/midpapi2/120.html
2.0ãããªãã®ããª