[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I display a PNG file??
- Subject: Re: How can I display a PNG file??
- From: davidf(at)dfanning.com (David Fanning)
- Date: Wed, 10 Jan 2001 08:18:13 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <3A5C430E.3CC4BF11@ehma.upc.es>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:22878
Miguel Angel Cordoba (cordoba@ehma.upc.es) writes:
> i am using the query_png and the read_png functions to read a png file.
> The read_png returns a 4 channel image and i don't know how to display
> it.
> I execute this commands:
>
> IDL> ok=query_png('intro.png',s)
> % Loaded DLM: PNG.
> IDL> help,s,/structure
> ** Structure <780f0>, 7 tags, length=36, refs=1:
> CHANNELS LONG 4
> DIMENSIONS LONG Array[2]
> HAS_PALETTE INT 0
> IMAGE_INDEX LONG 0
> NUM_IMAGES LONG 1
> PIXEL_TYPE INT 1
> TYPE STRING 'PNG'
> IDL> window,0
> IDL> wset,0
> IDL> image1=read_png('intro.png')
> IDL> tv,image1
> IDL> help,image1
> IMAGE1 BYTE = Array[4, 629, 288]
This image is a 24-bit RGB image, with an additional
alpha channel that can be used for blending images
together (and other things). To display a 4-channel
image correctly, you are going to have to use the
object graphics system in IDL. (Beyond the scope
of this discussion.)
But to see the image in the normal direct graphics
system, all you have to do is extract the RGB
channels, like this:
imageRGB = image1[0:2, *,*]
Then, you would display the image normally:
Device, Decomposed=1
TV, imageRGB, True=1
Or, if you don't want to mess around with the Decomposed
stuff and the True keyword, you can use the TVIMAGE command
from my web page:
TVImage, imageRGB
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155