transparent background [message #35296] |
Tue, 03 June 2003 09:59  |
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  |
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  |
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  |
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  |
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
|
|
|