首先使用 PImage 来实例化对象,再通过 loadImage 赋值,两层 for 循环遍历图片上的像素点,每隔5个像素点,画一个直径为3的圆。颜色通过 pic.get(x,y) 获取。 最后通过 save 函数来保存图片
首先使用PImage来实例化对象,再通过loadImage赋值,两层for循环遍历图片上的像素点,每隔5个像素点,画一个直径为3的圆。颜色通过pic.get(x,y)获取。
最后通过save函数来保存图片。
PImage pic;
int spacing=5;
void setup(){
pic=loadImage("steve.jpeg");
size(706, 644);
}
void draw(){
for (int x=spacing; x<width; x+=spacing) {
for (int y=spacing; y<height; y+=spacing) {
color c=pic.get(x, y);
fill(c);
noStroke();
ellipse(x, y, spacing*0.6, spacing*0.6);
}
}
save("image_2.jpg");
}


到此这篇关于java如何用Processing生成马赛克风格的图像的文章就介绍到这了,更多相关 Processing生成马赛克风格 内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!
