首页 > 其他 > 详细

使用像素生成图象

时间:2015-04-27 18:17:48      阅读:226      评论:0      收藏:0      [点我收藏+]

public void paint(Graphics g) {
// TODO 自动生成的方法存根

int h=400;
int pix[]=new int[w*h];
int dex=0;
for(int i=0;i<h;i++){
int red=(i*255)/(h-1);
for(int y=0;y<w;y++){
int blue=(y*255)/(w-1);
pix[dex++]=(255<<24)|(red<<16)|blue;
}
}
ImageProducer ip=new MemoryImageSource(w, h, pix, 0, w);
Image img=createImage(ip);
g.drawImage(img, 0, 0, this);

}

使用像素生成图象

原文:http://www.cnblogs.com/mafeng/p/4460722.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!