简体   繁体   English

将像素矩阵转换为图像

[英]Convert matrix of pixels into image

I want to convert this matrix into its original image that I have structured from.我想将此矩阵转换为我从中构建的原始图像。 I want to know the simplest way to do so.我想知道最简单的方法。

int pixels[width][height]; //Filled with pixels of colored image(jpg)

i wonder how you going to manage color codes from int type.我想知道你将如何管理 int 类型的颜色代码。

Anyways, i think code will be like this.无论如何,我认为代码会是这样的。 did not tested it没有测试过

BufferedImage image;
for(int i=0; i<pixels.length; i++) {
    for(int j=0; j<pixels[i].length; j++) {
        int a = pixels[i][j];
        Color newColor = new Color(R,G,B);
        image.setRGB(j,i,newColor.getRGB());
    }
}

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM