Issue with ARGB generation on unix for UTF-8 images
leonbloy opened this issue · 4 comments
From apoorve....@gmail.com on May 19, 2014 16:29:39
What steps will reproduce the problem? 1. Try to create a PNGJ png image with Japanese characters
2. The image has junk characters
3. It works in Windows but not on unix What is the expected output? What do you see instead? Should be Japanese What version of the product are you using? On what operating system? 2.0.0 (Linux) Please provide any additional information below.
Original issue: http://code.google.com/p/pngj/issues/detail?id=31
From hjg.com.ar@gmail.com on May 19, 2014 13:24:22
I don't understand. "create a PNGJ png image with Japanese characters" You mean text in a textual chunk? Or rendered text as an image? Please attach some code.
From apoorve....@gmail.com on May 19, 2014 13:43:34
Using the argb code from png site examples to write. Actually tried with java ImageIO.write as well and still get these Japanese characters wrong. Attaching a good and a bad image. Windows generates good and unix is bad
if (bi.getType() != BufferedImage.TYPE_INT_ARGB)
throw new PngjException("This method expects BufferedImage.TYPE_INT_ARGB");
ImageInfo imi = new ImageInfo(bi.getWidth(), bi.getHeight(), 8, true);
PngWriter pngw = new PngWriter(os, imi);
// pngw.setCompLevel(6); // tuning
// pngw.setFilterType(FilterType.FILTER_PAETH); // tuning
DataBufferInt db = ((DataBufferInt) bi.getRaster().getDataBuffer());
if (db.getNumBanks() != 1)
throw new PngjException("This method expects one bank");
SinglePixelPackedSampleModel samplemodel = (SinglePixelPackedSampleModel) bi.getSampleModel();
ImageLineByte line = new ImageLineByte(imi);
int[] dbbuf = db.getData();
byte[] scanline = line.getScanline();
for (int row = 0; row < imi.rows; row++)
{
int elem = samplemodel.getOffset(0, row);
for (int col = 0, j = 0; col < imi.cols; col++)
{
int sample = dbbuf[elem++];
scanline[j++] = (byte) ((sample & 0xFF0000) >> 16); // R
scanline[j++] = (byte) ((sample & 0xFF00) >> 8); // G
scanline[j++] = (byte) (sample & 0xFF); // B
scanline[j++] = (byte) (((sample & 0xFF000000) >> 24) & 0xFF); // A
}
pngw.writeRow(line, row);
}
pngw.end();
From hjg.com.ar@gmail.com on May 19, 2014 14:03:50
I think this has nothing to do with PNGJ (or with ImageIO.write), your problem is probably that your BufferedImage content (at the pixel level) is wrong, some problem at the rendering. PNGJ (or ImageIO.write) (or any other format writer) just saves the pixels, that's all.
From hjg.com.ar@gmail.com on May 19, 2014 18:55:06
Status: Invalid