Re: Alpha Blending inside of Widgets / Graphic Objects in Widgets [message #33841] |
Fri, 31 January 2003 09:49 |
Karl Schultz
Messages: 341 Registered: October 1999
|
Senior Member |
|
|
"Kay Bente" <k.bente@fz-juelich.de> wrote in message
news:b1dulh$3naa$1@zam602.zam.kfa-juelich.de...
> Hi,
>
> for the first part of your answer, I think you misunderstood me, i was
> thinking about to put an IDLgrImage or IDLgrWindow, or what ever of these
> objects i need (i don�t like objects) inside a Widget_Base, to display an
> image fusion.
If you want to do blending then I think you'll have to use Object Graphics
if you want the graphics support to do the blending for you. You can do a
lot of work and do the blending yourself with IDL code, but that's might be
slow and the amount of work involved depends a lot on what you are doing.
In IDL 5.6, the only objects that can really be blended are Images and
Polygons/Surface via a texture map.
You can configure Widget_Draw to use Object Graphics (GRAPHICS_LEVEL=2) and
then you can put your objects in that widget window.
> Or as another solution would it be possible, do get the fusioned image as
a
> truecolor image (256,256,3)-array out of an object.
You can use IDLgrBuffer to make an "off-screen" rendering buffer. You can
draw your objects into the buffer and then extract an RGB image.
If you can tell us more about what you want to draw, we can help more.
Also, there have been quite a few postings on this topic. You might want to
use Google to search the newsgroup for words like "transparency", "alpha",
"blending", etc.
Karl
|
|
|
Re: Alpha Blending inside of Widgets / Graphic Objects in Widgets [message #33843 is a reply to message #33841] |
Fri, 31 January 2003 09:09  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Kay Bente" wrote
> for the first part of your answer, I think you misunderstood me, i was
> thinking about to put an IDLgrImage or IDLgrWindow, or what ever of these
> objects i need (i don�t like objects) inside a Widget_Base, to display an
> image fusion.
Ahh, I see. So you want to use alpha blending to display 2 or more images
simultaneously. This can be done a number of ways, with or without objects.
Don't be afraid of the objects, they're really quite nice once you get to
know them.
At the full object end of the spectrum you can create two IDLgrImage objects
(with alpha channels) and display them, one on top of the other, in an
IDLgrWindow. Modulating image alpha will change the amount of fusion
between the two. David Fanning has written a fine program which does just
this called image_blend and it is available on his website
(www.dfanning.com)
Another option would be to create your two IDLgrImage objects and render to
an instance of IDLgrBuffer, then Read the buffer to get your fused image.
This wouldn't save you much over the first example.
The completely object free way would be to do it all by hand. The
"traditional" alpha blending equation is given in the docs to IDLgrImage and
it is something like:
result = ALPHA * srcPixel + ( 1 - ALPHA ) * destPixel
where
ALPHA - ranges from 0.0 to 1.0
result - Is the alpha blended color
srcPixel - Is the foreground pixel
destPixel- Is the background pixel
with an alpha of 0.0 the result will be the background pixel and with an
alpha of 1.0 the result will be the foreground pixel.
Use this equation on your R,G,B components of your image to calculate your
fused image.
Hope this helps.
-Rick
|
|
|
|
Re: Alpha Blending inside of Widgets / Graphic Objects in Widgets [message #33850 is a reply to message #33849] |
Fri, 31 January 2003 05:45  |
Kay Bente
Messages: 9 Registered: September 2001
|
Junior Member |
|
|
Hi,
for the first part of your answer, I think you misunderstood me, i was
thinking about to put an IDLgrImage or IDLgrWindow, or what ever of these
objects i need (i don�t like objects) inside a Widget_Base, to display an
image fusion.
Or as another solution would it be possible, do get the fusioned image as a
truecolor image (256,256,3)-array out of an object.
> You better start polishing your C skills as there is no built in function
> for this in IDL.
I think, that you�re right, it�s only so, that it would have been easy in
idl, to program, the GUI and the rest and IDL is the only language i know.
but thanks for your answer
Kay
|
|
|
Re: Alpha Blending inside of Widgets / Graphic Objects in Widgets [message #33859 is a reply to message #33850] |
Thu, 30 January 2003 09:54  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Kay Bente" wrote
> I would like to know, if it�s possible to put an Image Object inside a
> normal widget (instead of a Widget_Draw).
Well, yes and no. Widget_Draw is a widget and it seems quite normal to me
;)
I don't really understand what you are trying to do but I'll venture a guess
that you would like to place an image in your widget that appears to be part
of the widget base? For example, if I select Help->About IDL in IDLDE I get
a dialog with the IDL logo in the upper left corner. Upon inspection you'll
notice that the logo isn't square (because of the shadow). The only way to
do this would be to set the background color of your draw widget to the
color of your widget base then draw your image. The image will look as if
it is drawn directly in the base.
Finding the color of the widget base is the trick.
AFAIK there is no platform independent way to do this so any solution will
be limited. I have done this on Windows machines using the GetSysColor
function (delcared in winuser.h, link to user32.lib). It works like a charm
and there is no better way to distrat your users from the limitations of
your program than by putting up a flashy interface. :)
> p.s. Does someone know, if it�s possible to read and play .mp3 files?
You better start polishing your C skills as there is no built in function
for this in IDL.
You could read the compressed data using IDL. I'm sure the file format is
available on the web. With the compressed data in hand, you would need to
decompress it. This might not be that difficult. Find a few MP3 players
and look at the .dll (or .so) libraries they ship with. Chances are you
would be able to use IDL's CALL_EXTERNAL function to access the
decompression algorithm (you'll just need to find the entry point). For
short clips, you could decompress a section of the file and use IDL's
WRITE_WAV to create an uncompressed .wav file. Since IDL doesn't do much
more than ring it's bell, the easiest way to play the file would be to use
SPAWN to call an appropriate program. Extra credit would be given for using
Randall Frank's IDL_Tools .dlm package which includes an interface for
playing sound.
Now that sounds like a project.
-Rick
|
|
|