Re: Show an Image without opening file but by directly passing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Show an Image without opening file but by directly passing

Albert Cardona
If you are programming in java, the first thing to do is to browse the ImageJ
API. In there you can see that, in the package ij.process, an ImageProcessor
subclass will suit your needs. For example, a ByteProcessor. Then you can call
'createImage' from it to extract the awt.Image for display wherever you want,
or alternatively, wrap it in an ImagePlus, give the ImagePlus to a new
ImageCanvas, and add the ImageCanvas to your applet panel container (in this
way, zooming and panning will work without selecting any tools, with keys for
the zoom and the mouse+spacebar for panning).

For example, you can use the constructor:

ByteProcessor(int width, int height, byte[] pixels, java.awt.image.ColorModel
cm)

If you don't have a clue on the ColorModel classes, just create the
ByteProcessor with the constructor:

ByteProcessor(int width, int height)

and then use the 'setPixels' method to set the array. Be careful here to give a
proper array according to the width and height given at construction time.


If you need help in setting up your applet, please contact me offlist.


Albert

--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.pensament.net/java/
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com

--------------------------------------------------------------------
This message was sent using Webmail@INI: https://webmail.ini.ethz.ch