在MIDP2.0中操作图片像素[2]
[入库:2006年2月23日] [更新:2007年3月24日]
Height;
int count; public ShadowCanvas() { w = this.getWidth(); h = this.getHeight(); try { srcImage = Image.createImage("/av.png"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } imgWidth = srcImage.getWidth(); imgHeight = srcImage.getHeight(); // 制造原始图片的像素数组,用一个int来代表每一个像素,按位表示方式是:0xAARRGGBB srcRgbImage = new int[imgWidth * imgHeight]; // 获取原始图片的所有像素,参见MIDP APPI文档 srcImage.getRGB(srcRgbImage, 0, imgWidth, 0, 0, imgWidth, imgHeight); shadowRgbImage = new int[srcRgbImage.length]; System.arraycopy(srcRgbImage, 0, shadowRgbImage, 0, shadowRgbImage.length); // 渐变图片的所有像素已开始都是全透明的 for (int i = 0; i < shadowRgbImage.length; i++) { shadowRgbImage[i] &= 0x00ffffff; } new Thread(this).start(); } public void paint(Graphics g) { g.setColor(0, 0, 0); g.fillRect(0, 0, w, h); // 绘制渐变图片 g.drawRGB(shadowRgbImage, 0, imgWidth, (w - imgWidth) / 2, (h - imgHeight) / 2, imgWidth, imgHeight, true); g.setColor(0, 255, 0); g.drawString("count=" + count, w /
本文关键:在MIDP2.0中操作图片像素
本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)