blob: 23df5e0b81cf9a84c4b4154518f46f636ce2534e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<body>
<p>
<b>PNGJ: A simple library for reading/writing PNG images.</b>
</p>
<p>
Focused on high resolution images,
both huge in size (and hence not appropiate to be loaded in memory, eg. as a BufferedImage)
and quality (the library is dedicated to truecolor images, with 8 and 16 bits per sample,
with or without alpha). It provides basic line-oriented reading and writing capabilities.
</p>
<p>
A quick example: this code reads a PNG image file (true colour, 8-16 bpp, RGB-RGBA) and
rewrites it cutting the red channel by two.
</p>
<pre>
public static void decreaseRed(String origFilename, String destFilename) {
PngReader pngr = new PngReader(origFilename);
PngWriter pngw = new PngWriter(destFilename, pngr.imgInfo);
pngw.setOverrideFile(true); // allows to override writen file if it already exits
System.out.println(pngr.toString());
pngw.prepare(pngr); // not necesary; but this can copy some informational chunks from original
int channels = pngr.imgInfo.channels;
if(channels<3) throw new RuntimeException("Only for truecolour images");
for (int row = 0; row < pngr.imgInfo.rows; row++) {
ImageLine l1 = pngr.readRow(row);
for(int j=0;j<pngr.imgInfo.cols;j++)
l1.scanline[j*channels]/=2;
pngw.writeRow(l1);
}
pngr.end();
pngw.end();
}
</pre>
<p>
See the docs and source of the samples for more.
</p>
http://code.google.com/p/pngj/<br>
<a href="http://code.google.com/p/pngj/">PNGJ</a>
</body>
</html>
|