comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » transparent background
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
transparent background [message #35296] Tue, 03 June 2003 09:59 Go to next message
craigni is currently offline  craigni
Messages: 2
Registered: August 2000
Junior Member
Hi all,

I'm trying to import a plot into PowerPoint, but I'd like the
background to be transparent. I've been fooling around with the
metafile display device, e.g.

SET_PLOT, 'METAFILE'

but so far have been unable to achieve a transparent background. Any
ideas?

Many TIA,
Craig
Re: transparent background [message #35358 is a reply to message #35296] Thu, 05 June 2003 13:22 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
"David Fanning" wrote in message..
> Rick Towler writes:
>
>> You didn't really fool around for 20 minutes, did you?
>
> Indeed I did. I thought it might take five. And now
> I've just spent another 15. :-)
>
>> With the B/W linear color table loaded:
>>
>> IDL> test = BYTARR(200,200)
>> IDL> test[100:199,*] = 200
>> IDL> tvlct, r,g,b,/get
>> IDL> write_png,'test.png',test,r,g,b,TRANSPARENT=[0]
>>
>>
>> In PP, Insert -> Picture -> From File... and select 'test.png'
>>
>> I have a 200x200 image, right half is lt. gray, left half is
transparent.
>>
>> Load test.png up in Photoshop and the left half of the image is
transparent
>> too.
>
> Well, I can see this works. But why doesn't my test
> program work?

It looks like WRITE_PNG only accepts "0" as a valid transparent pixel index
value. I can get your program to work if I load your background at 0 and
specify 0 as the transparent index but it will not work with any other
value. it looks like I was just lucky :)

Another annoying thing I noticed is that the VERBOSE keyword isn't verbose
at all. I didn't get any additional output with it set.

I would submit these as bugs.


-Rick
Re: transparent background [message #35360 is a reply to message #35296] Thu, 05 June 2003 13:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer (R.Bauer@fz-juelich.de) writes:

> did you have tried with 24bit or 16bit color resolution.
> I believe you have 16bit used.
>
> If it's 16bit then it is the same problem JD postest on 22.5.
> I added an other example there.
>
> I recognized this during beta test of idl5.6.

I used TVRD in the Z buffer. That is surely an 8-bit
color resolution!

I don't think it is the same problem. I *know* I have
pixels with that value (some 300K of them!). They
just don't go transparent and I can't figure out why
not.

Cheers,

David

P.S. Let's just say I'm reluctant to spend much more
time on it and blow my cover about knowing everything
about IDL without having to do all the hard work. :-(

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: transparent background [message #35361 is a reply to message #35296] Thu, 05 June 2003 12:43 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning wrote:

> Rick Towler (rtowler@u.washington.edu) writes:
>
>> You didn't really fool around for 20 minutes, did you?
>
> Indeed I did. I thought it might take five. And now
> I've just spent another 15. :-)
>
>> With the B/W linear color table loaded:
>>
>> IDL> test = BYTARR(200,200)
>> IDL> test[100:199,*] = 200
>> IDL> tvlct, r,g,b,/get
>> IDL> write_png,'test.png',test,r,g,b,TRANSPARENT=[0]
>>
>>
>> In PP, Insert -> Picture -> From File... and select 'test.png'
>>
>> I have a 200x200 image, right half is lt. gray, left half is transparent.
>>
>> Load test.png up in Photoshop and the left half of the image is
>> transparent too.
>
> Well, I can see this works. But why doesn't my test
> program work?
>
> PRO TEST
> thisDev = !D.Name
> white = FSC_Color('white', !D.Table_Size-2, Decomposed=0)
> red = FSC_Color('red', !D.Table_Size-3, Decomposed=0)
> green = FSC_Color('green', !D.Table_Size-4, Decomposed=0)
> Set_Plot, 'Z', /Copy
> Erase
> Plot, findgen(11), Color=red, Background=white, /NoData
> Oplot, findgen(11), Color=green
> snapshot = TVRD()
> tvlct, r,g,b,/get
> Set_Plot, thisDev
> write_png,'tester.png',snapshot,r,g,b,TRANSPARENT=[!D.Table_ Size-2]
> Print, !D.Table_Size-2
> I = Where(snapshot EQ !D.Table_Size-2, count) & Print, count
> END
>
> My background (index 254) is white. I want that to be the transparent
> pixel value. There are 304,055 pixels in my image with this value.
> You'd think a *few* of them would be transparent. But no, when
> I put this into Powerpoint, I get an image with a white background.
>
> Any ideas?
>
> Cheers,
>
> David

David,

did you have tried with 24bit or 16bit color resolution.
I believe you have 16bit used.

If it's 16bit then it is the same problem JD postest on 22.5.
I added an other example there.

I recognized this during beta test of idl5.6.

Reimar



--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: transparent background [message #35364 is a reply to message #35296] Thu, 05 June 2003 12:16 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rick Towler (rtowler@u.washington.edu) writes:

> You didn't really fool around for 20 minutes, did you?

Indeed I did. I thought it might take five. And now
I've just spent another 15. :-)

> With the B/W linear color table loaded:
>
> IDL> test = BYTARR(200,200)
> IDL> test[100:199,*] = 200
> IDL> tvlct, r,g,b,/get
> IDL> write_png,'test.png',test,r,g,b,TRANSPARENT=[0]
>
>
> In PP, Insert -> Picture -> From File... and select 'test.png'
>
> I have a 200x200 image, right half is lt. gray, left half is transparent.
>
> Load test.png up in Photoshop and the left half of the image is transparent
> too.

Well, I can see this works. But why doesn't my test
program work?

PRO TEST
thisDev = !D.Name
white = FSC_Color('white', !D.Table_Size-2, Decomposed=0)
red = FSC_Color('red', !D.Table_Size-3, Decomposed=0)
green = FSC_Color('green', !D.Table_Size-4, Decomposed=0)
Set_Plot, 'Z', /Copy
Erase
Plot, findgen(11), Color=red, Background=white, /NoData
Oplot, findgen(11), Color=green
snapshot = TVRD()
tvlct, r,g,b,/get
Set_Plot, thisDev
write_png,'tester.png',snapshot,r,g,b,TRANSPARENT=[!D.Table_ Size-2]
Print, !D.Table_Size-2
I = Where(snapshot EQ !D.Table_Size-2, count) & Print, count
END

My background (index 254) is white. I want that to be the transparent
pixel value. There are 304,055 pixels in my image with this value.
You'd think a *few* of them would be transparent. But no, when
I put this into Powerpoint, I get an image with a white background.

Any ideas?

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: TVRD, Decomposed = ? and 24bit display
Next Topic: M-SSA

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:44:48 PDT 2025

Total time taken to generate the page: 0.00678 seconds