Hi I have been meaning to post this for a while, It is some source for a
logoPainter that I made for an upcomming bioinformatics paper regarding
the correction for signals in a biased genome.

It is based on a Biojava-live (although perhaps a slightly earlier
release so it made need the odd tweak) Anyhow it demonstrates some writing
to Jpeg Tiff bmp etc. Uses the Java Advanced Image Library (JAI 1.1 from
Sun). Please feel free to use / review the code as you see fit. Perhaps
ask permission before selling it ;)

I would be happy for it to be made part of the CVS if people want. It
could probably do with some peer review so to speak as it has a few rough
edges in the code that others might be able to make more elegant.

Enjoy

Mark



On Fri, 11 Jan 2002, Bert Coessens wrote:

> Dear all,
> 
> Does anybody know how to write a graphics object to a jpeg file? I
> already tried almost everything but still with no result. The code
> beneath is what I think should work, but if I run it, I only get a black
> image of 300 by 300. Can anybody tell me what I'm doing wrong?
> 
> * variable dist is some distance
> * sLogo is not a null object, I can visualise it inside a JFrame object
> 
> code:
>     {
>         DistributionLogo sLogo = new DistributionLogo();
>         TextLogoPainter logoPainter = new TextLogoPainter();
>         sLogo.setLogoPainter(logoPainter);
>         sLogo.setStyle(new DNAStyle());
>         sLogo.setDistribution(dist);
> 
>         BufferedImage bufIm = new BufferedImage(300, 300,
> BufferedImage.TYPE_INT_RGB);
>         Graphics g = bufIm.createGraphics();
>         logoPainter.paintLogo(g, sLogo);
> 
>         File outfile = new File("motif.jpeg");
>         FileOutputStream outstream = new FileOutputStream(outfile);
>         com.sun.image.codec.jpeg.JPEGImageEncoder encoder =
> 
> com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(outstream);
>         encoder.encode(img);
>     }
> 
> Thanks in advance!!
> Bert
> 
> _______________________________________________
> Biojava-l mailing list  -  [EMAIL PROTECTED]
> http://biojava.org/mailman/listinfo/biojava-l
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Schreiber                  Ph: 64 3 4797875
Rm 218                          email [EMAIL PROTECTED]
Department of Biochemistry
University of Otago             
PO Box 56
Dunedin
New Zealand
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Attachment: logoPaint.tar.gz
Description: Binary data

Reply via email to