下载一个文本misc.txt,打开来一看,什么鬼,全是3个一组的数字
马上想到是RGB三原色,一共61366组,就先创建一个256*256的白色画布
这就是白色画布,不用怀疑,你马上就能看到了
然后就是对白色画布的填充
创建一个PicTest.java,代码如下:
public class PicTest {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream("G:\\misc100.txt")));
int i,j;
String line = br.readLine();
int rgb[] = new int[3];
File file = new File("G:\\1.jpg");// 实例化file对象,并设置读取图片路径
BufferedImage bi = null; // 像素缓冲区开始为空
bi = ImageIO.read(file);
int width = bi.getWidth();
int height = bi.getHeight();
int minx = bi.getMinX();
int miny = bi.getMinY();
for (i = 0; i < width; i++) {
for (j = 0; j < height; j++) {
// int pixel = bi.getRGB(i, j);
// rgb[0] = (pixel & 0xff0000) >> 16;
// rgb[1] = (pixel & 0xff00) >> 8;
// rgb[2] = (pixel & 0xff);
// System.out.println("i=" + i + ",j=" + j + ":(" + rgb[0] + ","
// + rgb[1] + "," + rgb[2] + ")"+pixel);
if(line == null) break;
String[] rgbs=line.toString().split(",");
rgb[0]=new Integer(rgbs[0]);
rgb[1]=new Integer(rgbs[1]);
rgb[2]=new Integer(rgbs[2]);
bi.setRGB(i, j, Integer.parseInt(Integer.toHexString(rgb[0])+Integer.toHexString(rgb[1])+Integer.toHexString(rgb[2]),16));
//bi.setRGB(i, j, Integer.parseInt("ffffff",16));
line = br.readLine();
}
}
ImageIO.write(bi, "JPEG", file); //写入文件
br.close();
}
}
OK,我们来看看效果
什么鬼,调整一下图片的高和宽,变成256和245
OK,找到了flag{ youc@n'tseeme }
提交,通过!