Hi,

thats pretty simple. Create a reader like this (creates a png with current timestamp in red):

public class TestImageReader extends AbstractReader {

    public String getMimeType() {
        return "image/png";
    }

public void generate() throws IOException, SAXException, ProcessingException {
        String date = DateFormat.getDateTimeInstance().format(new Date());
        Font font = Font.decode(Font.SERIF).deriveFont(80.f);
TextLayout textLayout = new TextLayout(date, font, new FontRenderContext(null, true, true));
        Rectangle2D bounds = textLayout.getBounds();
BufferedImage image = new BufferedImage((int) bounds.getWidth(), (int) bounds.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = image.createGraphics();
        g.setColor(Color.RED);
        textLayout.draw(g, (float) -bounds.getX(), (float) -bounds.getY());
        g.dispose();
        ImageIO.write(image, "png", this.out);
    }

}

in your sitemap define and use this reader:
<map:components>
<map:readers>
<map:reader name="timeimg" src="test.TestImageReader" />
</map:readers>
</map:components>

...

<map:match pattern="time.jpg">
  <map:read type="timeimg" />
</map:match>


hth
Thomas


Am 21.05.2011 14:00, schrieb JeVeoy:

First of all: thank you so much for helping me out, Steven&  Thomas!

Then: I've tried my best to see if I could get a working example to run
using either javax.imageio.ImageIO.write(RenderedImage, String,
OutputStream) or AbstractReader.out, but to no luck. Googling didn't quite
help either. I'm very sorry for my lack of knowledge... Hope you can forgive
me.

Pipeline for an image-reader is, as far as I know, defined in sitemap.xmap
like this:

<map:match pattern="*.jpg">
   <map:read type="image" src="path/{1}.png" mime-type="image/png">
   </map:read>
</map:match>

How can I make use of AbstractReader.out in this definition?


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to