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

Home » Public Forums » archive » how do I create an image file from an object graphics window?
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
how do I create an image file from an object graphics window? [message #40101] Thu, 22 July 2004 23:21 Go to next message
holgi0251 is currently offline  holgi0251
Messages: 4
Registered: June 2004
Junior Member
Hi,

I want to save the RGB-image displayed in an object graphics window
(IDLgrWindow) in a TIFF or JPEG file. When I use TVRD to copy the
image from the window, the resulting image is empty. My impression is,
that TVRD does not work with object graphics.
My question: how do I create an image file from an object graphics
window?

Thanks,
Holger
Re: how do I create an image file from an object graphics window? [message #40212 is a reply to message #40101] Tue, 27 July 2004 10:17 Go to previous messageGo to next message
stef is currently offline  stef
Messages: 6
Registered: April 2004
Junior Member
Hello Holger
The following code snippets might help you. The input argument is the
object graphic window object. Depending on the chosen file ending it
creates a JPEG, PNG or TIFF image from the object window. If you want
higher quality (e.g. for printing, change the dimensions arguments to
a higher value)

Also, below are the procedure I use to copy the image to the
clipboard, one is
for BMP, the other for Vector output. (Can be easily copied into MS
Word or Powerpoint)

Hope this helps,
Stefan

PRO CV_Save_Image, window_o
filters = [['*.jpg', '*.png', '*.tif'], $
['JPG', 'PNG (lossless)', 'TIF']]
filename = DIALOG_PICKFILE(/WRITE, FILTER = filters,
/OVERWRITE_PROMPT, DEFAULT_EXTENSION='JPG')
print, filename
IF (filename) THEN BEGIN
image_o=OBJ_NEW('IDLgrImage')
image_o=window_o->Read()
image_o->GetProperty, DATA=image_data
extension=STRLOWCASE(STRMID(filename,STRLEN(filename)-4,4))
CASE extension OF
'.jpg': WRITE_JPEG, filename, image_data, TRUE=1
'.png': WRITE_PNG, filename, image_data
'.tif': WRITE_TIFF, filename, Reverse(image_data,3)
ELSE: ;do nothing
ENDCASE
Obj_Destroy, image_o
ENDIF
END

PRO CV_CopyClipboardBMP, window_o
window_o->GetProperty, GRAPHICS_TREE=view_o
window_o->GetProperty, DIMENSIONS=dimensions

clipboard_o= OBJ_NEW('IDLgrClipboard', QUALITY = 2,
DIMENSIONS=dimensions)
clipboard_o->Draw, view_o
Obj_Destroy, clipboard_o
END

PRO CV_CopyClipboardVector, window_o
window_o->GetProperty, GRAPHICS_TREE=view_o
window_o->GetProperty, DIMENSIONS=dimensions

clipboard_o= OBJ_NEW('IDLgrClipboard', QUALITY = 2,
DIMENSIONS=dimensions)
clipboard_o->Draw, view_o, /VECTOR
Obj_Destroy, clipboard_o
END



holgi0251@lycos.de (Holger B.) wrote in message news:<2c8cff70.0407222221.1f90f37d@posting.google.com>...
> Hi,
>
> I want to save the RGB-image displayed in an object graphics window
> (IDLgrWindow) in a TIFF or JPEG file. When I use TVRD to copy the
> image from the window, the resulting image is empty. My impression is,
> that TVRD does not work with object graphics.
> My question: how do I create an image file from an object graphics
> window?
>
> Thanks,
> Holger
Re: how do I create an image file from an object graphics window? [message #40240 is a reply to message #40101] Fri, 23 July 2004 11:30 Go to previous messageGo to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 23 Jul 2004 10:28:10 -0600, Karl Schultz wrote:

>
> "Haje Korth" <haje.korth@jhuapl.edu> wrote in message
> news:cdqth5$qro$1@aplcore.jhuapl.edu...
>> Holger,
>> I have used 'idlgrclipboard' object in the past, which can create
> Postscript
>> file. However, the implementation in 6.0 is still buggy. 6.1 will be
> better,
>> there may still be some issues with alpha blending. Any way, if your
>> view/scene is not too complicated it may work for you. A note on the
>> side: It amazes me that RSI worked out so many details on making object
>> graphics look pretty and totoally forgot to spend the time working on
>> creating descent quality output of the graphics. In order to get what I
>> want, I
> have
>> to write every code twice, once in object graphics for the screen and
>> then use direct graphics techniques to create the PS file. Not very
>> efficient.....
>
> Remember that the clipboard has both bitmap and vector modes. The bitmap
> mode captures the contents of the scene exactly as you would see it on the
> screen. You can also do pretty much the same thing by getting the data
> out of the grBuffer and grWindow objects.
>
> Yes, vector output in 6.1 is quite a bit better, but we still need to
> understand that vector output cannot possibly recreate all the graphical
> features that you might use on the display. Vector output systems (e.g.,
> PostScript, Windows metafiles) are not really "3D" in any way, while
> Object Gaphics obviously is a 3D system. It's difficult to map a system
> with high capabilities onto ones with lesser capabilities. For example,
> vector systems do not have depth buffers. IDL does a crude depth sort in
> vector output to approximate the effect of a depth buffer, but it won't
> sort things out completely. Similar restrictions apply for things like
> alpha blending.
>
> One of the main motivations for Object Graphics vector output was to
> reduce the size of the graphics output. In bitmap mode, even a simple
> plot with a few dozen lines and some text would require several MB of
> space, depending on the dimensions of the drawable, which seems silly when
> there is so little data actually in the plot. With vector output, the
> same data can be represented with a few dozen line plot commands and some
> text strings, which adds up to a PostScript file of 1K or so in length So
> vector output can be a big win when working with plots, charts, and other
> visualizations that are more "2D" than "3D" and don't use a lot of
> advanced rendering features. Bitmap output is better when you need to
> preserve all those "3D" qualities.

Speaking entirely without having used Object Graphics, but the problem
with bitmap output is always the tradeoff between absurdly large
sizes, and too coarse resolution. When object scenes contains lines,
text, and other glyphs, the output will not be good if copied at
screen resolution and printed or sent to a journal. Ideally, an
output system could do a combination: take a bitmap "background" of
everything which is too complicated for, e.g., Postscript to handle,
and overlay then lines, text, glyphs, etc. as vector entities. It may
not be trivial to divide items into non-handleable vs. handleable, but
it would surely produce better results at smaller output sizes.

JD
Re: how do I create an image file from an object graphics window? [message #40244 is a reply to message #40101] Fri, 23 July 2004 09:28 Go to previous messageGo to next message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
"Haje Korth" <haje.korth@jhuapl.edu> wrote in message
news:cdqth5$qro$1@aplcore.jhuapl.edu...
> Holger,
> I have used 'idlgrclipboard' object in the past, which can create
Postscript
> file. However, the implementation in 6.0 is still buggy. 6.1 will be
better,
> there may still be some issues with alpha blending. Any way, if your
> view/scene is not too complicated it may work for you. A note on the side:
> It amazes me that RSI worked out so many details on making object graphics
> look pretty and totoally forgot to spend the time working on creating
> descent quality output of the graphics. In order to get what I want, I
have
> to write every code twice, once in object graphics for the screen and then
> use direct graphics techniques to create the PS file. Not very
> efficient.....

Remember that the clipboard has both bitmap and vector modes. The bitmap
mode captures the contents of the scene exactly as you would see it on the
screen. You can also do pretty much the same thing by getting the data out
of the grBuffer and grWindow objects.

Yes, vector output in 6.1 is quite a bit better, but we still need to
understand that vector output cannot possibly recreate all the graphical
features that you might use on the display. Vector output systems (e.g.,
PostScript, Windows metafiles) are not really "3D" in any way, while Object
Gaphics obviously is a 3D system. It's difficult to map a system with high
capabilities onto ones with lesser capabilities. For example, vector
systems do not have depth buffers. IDL does a crude depth sort in vector
output to approximate the effect of a depth buffer, but it won't sort things
out completely. Similar restrictions apply for things like alpha blending.

One of the main motivations for Object Graphics vector output was to reduce
the size of the graphics output. In bitmap mode, even a simple plot with a
few dozen lines and some text would require several MB of space, depending
on the dimensions of the drawable, which seems silly when there is so little
data actually in the plot. With vector output, the same data can be
represented with a few dozen line plot commands and some text strings, which
adds up to a PostScript file of 1K or so in length So vector output can be
a big win when working with plots, charts, and other visualizations that are
more "2D" than "3D" and don't use a lot of advanced rendering features.
Bitmap output is better when you need to preserve all those "3D" qualities.

Karl
Re: how do I create an image file from an object graphics window? [message #40247 is a reply to message #40101] Fri, 23 July 2004 04:41 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Holger,
I have used 'idlgrclipboard' object in the past, which can create Postscript
file. However, the implementation in 6.0 is still buggy. 6.1 will be better,
there may still be some issues with alpha blending. Any way, if your
view/scene is not too complicated it may work for you. A note on the side:
It amazes me that RSI worked out so many details on making object graphics
look pretty and totoally forgot to spend the time working on creating
descent quality output of the graphics. In order to get what I want, I have
to write every code twice, once in object graphics for the screen and then
use direct graphics techniques to create the PS file. Not very
efficient.....

Haje


"Holger B." <holgi0251@lycos.de> wrote in message
news:2c8cff70.0407222221.1f90f37d@posting.google.com...
> Hi,
>
> I want to save the RGB-image displayed in an object graphics window
> (IDLgrWindow) in a TIFF or JPEG file. When I use TVRD to copy the
> image from the window, the resulting image is empty. My impression is,
> that TVRD does not work with object graphics.
> My question: how do I create an image file from an object graphics
> window?
>
> Thanks,
> Holger
Re: how do I create an image file from an object graphics window? [message #40248 is a reply to message #40101] Fri, 23 July 2004 03:27 Go to previous messageGo to next message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
Diract graphics is not campatible with objects graphics.

If you want a screenshot of the IDLgrWindow you can use:
oWindow->GetProperty, IMAGE_DATA=img
WRITE_PNG, name, img

or you can use the method "read" of the idlgrwindow.

Bye.



Holger B. wrote:
> Hi,
>
> I want to save the RGB-image displayed in an object graphics window
> (IDLgrWindow) in a TIFF or JPEG file. When I use TVRD to copy the
> image from the window, the resulting image is empty. My impression is,
> that TVRD does not work with object graphics.
> My question: how do I create an image file from an object graphics
> window?
>
> Thanks,
> Holger
Re: how do I create an image file from an object graphics window? [message #40278 is a reply to message #40101] Thu, 29 July 2004 09:19 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Haje Korth wrote:

> Karl,
> oops, for some reason I did not see your post until now. I do not expect the
> clipboard object to produce miracles. All I expect it to do is to produce
> the same quality as set_plot,'ps', which produces nice vector output. Is
> this asking for too much? I do not use any projections, shadings, etc. All I
> do is overlaying images with alpha blending.

Yes, you are asking too much. :)

I don't know about WMF but postscript 3 doesn't support alpha blending
for vector elements. The current pdf spec does, and word is that 4 will
but for now the only way is thru hacks of one sort or another. Even the
major vector illustration packages have trouble with alpha blending
elements (most produce decent on screen results but fall down when you
go to print). So for now I don't think you'll get your alpha blending.


> The bitmapped mode of the clipboard object is extremely lousy, as all fonts
> are bitmapped too.

Everyone's bustin' on the bitmap.

FWIW, we submit bitmaps for publication all of the time and I think they
look pretty good on the page. For really big figures you are out of
luck but a max of around 10" x 10" should cover most situations. (I am
still trying to work out a way to stitch together multiple images from a
perspective projection. Any thoughts are welcome :)

And you can always export your bitmap and add your annotations in a
vector drawing program.

-Rick
Re: how do I create an image file from an object graphics window? [message #40295 is a reply to message #40244] Wed, 28 July 2004 05:46 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Karl,
oops, for some reason I did not see your post until now. I do not expect the
clipboard object to produce miracles. All I expect it to do is to produce
the same quality as set_plot,'ps', which produces nice vector output. Is
this asking for too much? I do not use any projections, shadings, etc. All I
do is overlaying images with alpha blending. The bitmapped mode of the
clipboard object is extremely lousy, as all fonts are bitmapped too. The
vector mode still has problems with alpha blending. I am not sure whether
RSI is aware of this problem. I tested this for IDL 6.1 but never reported
the problem because my example is longer than 10 lines. My past experience
shows that they reject examples that are too long. Too bad, now they have to
wait until I find the time to boil this down. And since I do not get paid
for debugging IDL, this might just take some time.

Cheers,
Haje

"Karl Schultz" <kschultz_no_spam@rsinc.com> wrote in message
news:10g2f4f7ra0roed@corp.supernews.com...
>
> "Haje Korth" <haje.korth@jhuapl.edu> wrote in message
> news:cdqth5$qro$1@aplcore.jhuapl.edu...
>> Holger,
>> I have used 'idlgrclipboard' object in the past, which can create
> Postscript
>> file. However, the implementation in 6.0 is still buggy. 6.1 will be
> better,
>> there may still be some issues with alpha blending. Any way, if your
>> view/scene is not too complicated it may work for you. A note on the
side:
>> It amazes me that RSI worked out so many details on making object
graphics
>> look pretty and totoally forgot to spend the time working on creating
>> descent quality output of the graphics. In order to get what I want, I
> have
>> to write every code twice, once in object graphics for the screen and
then
>> use direct graphics techniques to create the PS file. Not very
>> efficient.....
>
> Remember that the clipboard has both bitmap and vector modes. The bitmap
> mode captures the contents of the scene exactly as you would see it on the
> screen. You can also do pretty much the same thing by getting the data
out
> of the grBuffer and grWindow objects.
>
> Yes, vector output in 6.1 is quite a bit better, but we still need to
> understand that vector output cannot possibly recreate all the graphical
> features that you might use on the display. Vector output systems (e.g.,
> PostScript, Windows metafiles) are not really "3D" in any way, while
Object
> Gaphics obviously is a 3D system. It's difficult to map a system with
high
> capabilities onto ones with lesser capabilities. For example, vector
> systems do not have depth buffers. IDL does a crude depth sort in vector
> output to approximate the effect of a depth buffer, but it won't sort
things
> out completely. Similar restrictions apply for things like alpha
blending.
>
> One of the main motivations for Object Graphics vector output was to
reduce
> the size of the graphics output. In bitmap mode, even a simple plot with
a
> few dozen lines and some text would require several MB of space, depending
> on the dimensions of the drawable, which seems silly when there is so
little
> data actually in the plot. With vector output, the same data can be
> represented with a few dozen line plot commands and some text strings,
which
> adds up to a PostScript file of 1K or so in length So vector output can
be
> a big win when working with plots, charts, and other visualizations that
are
> more "2D" than "3D" and don't use a lot of advanced rendering features.
> Bitmap output is better when you need to preserve all those "3D"
qualities.
>
> Karl
>
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Translate characters/string size to data/normal coordinates?
Next Topic: IDL program

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

Current Time: Wed Oct 08 10:58:07 PDT 2025

Total time taken to generate the page: 0.00491 seconds