incubator-sanselan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philipp Koch" <philipp.k...@day.com>
Subject Re: tEXt chunk in PNG
Date Mon, 04 Aug 2008 15:19:15 GMT
hi ben,
> Firstly is there a user forum for the project I can direct my queries
> to?
currently, there is only the dev list to post questions.

> Secondly, I would like to know if Sanselan is at the point where a tEXt
> chunk can be inserted into a PNG image. If so, how is this done? I have
> been using v0.94 but I can't make it do what I need.
with sanselan you are able to get a BufferedImage:
File file = someFile;
BufferedImage image = Sanselan.getBufferedImage(file);

you can than modify the BufferedImage by using Java2D:
Graphics2D g2 = image.createGraphics();
		
g2.setColor(Color.black);
g2.setFont(font);
g2.drawString(text, 80,1440);

and save the image with sanselan:
OutputStream os = someOutputStream;
Sanselan.writeImage(image, os, format, optional_params);

see http://incubator.apache.org/sanselan/site/sampleusage.html for more samples.

hope this helps.

regards,
philipp

On Mon, Aug 4, 2008 at 5:06 PM,  <Ben.Fears@generaldynamics.uk.com> wrote:
> Hi,
>
>
>
> I have a couple of questions regarding Sanselan.
>
>
>
> Firstly is there a user forum for the project I can direct my queries
> to?
>
>
>
> Secondly, I would like to know if Sanselan is at the point where a tEXt
> chunk can be inserted into a PNG image. If so, how is this done? I have
> been using v0.94 but I can't make it do what I need.
>
>
>
> I wish to embed an XML String containing meta data describing the image
> file. I have written the function below. I think I have generated the
> PNGChunktEXt correctly but without seeing an example I am not sure. If
> it is correct, I still I don't know how to get it into the byte array
> holding the png image.
>
>
>
> I would appreciate any advice you could give.
>
>
>
>            static public byte [] changePngMetadata(byte [] pngImage,
> String xmlString) throws ImageReadException, IOException
>
>            {
>
>
>
>                        String txtString = "TcsMetaData" + '\0' +
> xmlString;
>
>
>
>                        PngCrc pngCrc = new PngCrc();
>
>                        int iCRC = pngCrc.crc(txtString.getBytes(),
> txtString.length());
>
>
>
>                        //May want to use compressed text instead. Do I
> need to compress the text string separately?
>
>                        PNGChunktEXt txt = new
> PNGChunktEXt(txtString.length(), PngConstants.tEXt, iCRC,
> txtString.getBytes());
>
>
>
>                        String kw = txt.getKeyword();
>
>                        String tx = txt.getText();
>
>
>
>                        //How do I insert txt into pngImage?
>
>
>
>                        return pngImage;
>
>            }
>
>
>
> Regards,
>
>
>
> Ben
>
>
>
>
>
> This email and any files attached are intended for the addressee and may contain information
of a confidential nature. If you are not the intended recipient, be aware that this email
was sent to you in error and you should not disclose, distribute, print, copy or make other
use of this email or its attachments. Such actions, in fact, may be unlawful. In compliance
with the various Regulations and Acts, General Dynamics United Kingdom Limited reserves the
right to monitor (and examine for viruses) all emails and email attachments, both inbound
and outbound. Email communications and their attachments may not be secure or error- or virus-free
and the company does not accept liability or responsibility for such matters or the consequences
thereof.  General Dynamics United Kingdom Limited, Registered Office: 100 New Bridge Street,
London EC4V 6JA. Registered in England and Wales No: 1911653.
>

Mime
View raw message