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

Home » Public Forums » archive » Transparent PNG file in PowerPoint
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Transparent PNG file in PowerPoint [message #35338] Tue, 10 June 2003 10:32
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

After several rounds of back and forth with the good
folks at RSI, we have finally discovered how to produce
transparent PNG output for inclusion into software such
as PowerPoint.

The TRANSPARENT keyword in WRITE_PNG should be a 256-element
vector. The vector would represent possible values in your
2D image. Any value that you wanted to be transparent would
have a value of 0 in the vector, while any value that you
wanted totally opaque would have the value of 255. You
could select the "degree" of transparency by varying the
values between 0 and 255 in the transparency vector.

So, for example, start with all pixels opaque:

t = BytArr(256) + 255B

If you want all pixels in your image with value 100
to be transparent:

t[100] = 0

If you want all pixels in your image with the value
of 50 to 75 to be semi-transparent:

t[50:75] = 128

Here is a test program that produces a plot with a
transparent background in PowerPoint:

;*************************************************
PRO Test
thisDev = !D.Name
loadct, 0
TVLCT, 255, 255, 255, !D.Table_Size-2 ; White
TVLCT, 0, 255, 0, !D.Table_Size-3 ; Green
TVLCT, 255, 0, 0, !D.Table_Size-4 ; Red
TVLCT, r, g, b, /Get


device, decomposed=0
Set_Plot, 'Z', /Copy
Erase
Plot, findgen(11), Color=!D.Table_Size-4, $
Background = !D.Table_Size-2, /NoData
OPlot, findgen(11), Color=!D.Table_Size-3
snapshot = TVRD()
Set_Plot, thisDev

; All are 0 so all values 0-255 are completely
; transparent (I.e, have value of 0).

t = bytarr(256)

; Set values !D.Table_Size-3 and !D.Table_Size-4 to
; be not transparent (I.e., have value 255).

t[[!D.Table_Size-3,!D.Table_Size-4]] = 128

WRITE_PNG,'transparent_test.png', $
snapshot, r, g, b, TRANSPARENT = t
END
;*************************************************

Cheers,

David
[Message index]
 
Read Message
Previous Topic: ICG IDL Library
Next Topic: IDL 5.6 License Question

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

Current Time: Sat Oct 11 14:38:13 PDT 2025

Total time taken to generate the page: 1.52750 seconds