| Re: annotated text without using graphics device in IDL? [message #35058] |
Wed, 07 May 2003 11:11  |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
"Howard Taylor" <howard.taylor@jhuapl.edu> wrote in message
news:b9bfce$b5j$1@houston.jhuapl.edu...
> I'd like to annotate an image without having to first draw the text on the
> active graphics display and then read the image back. This undesirable
> method might look like:
>
> a=indgen(256,256)
> tv,a
> xyouts,100,100,'this text',/device
> b=tvrd()
>
>
> Instead, I'd like an approach that doesnt rely on the graphics device at
> all. It might be called in this way:
>
> a=findgen(256,256)
> b = imgtext( a, 100,100,'this text' )
>
> As a result, b is an image whose contents have been altered to include the
> text.
>
> Anybody seen this sort of thing for IDL?
I don't think you can avoid having some sort of graphics device selected.
However you can use the Z-buffer graphics device which exists only in
memory, and does not require a graphics window:
ncol = 256
nrow = 256
a = dist(ncol, nrow)
entry_device = !d.name
set_plot, 'Z'
device, set_resolution=[ncol, nrow], set_colors=256, z_buffering=0
tv, bytscl(a)
xyouts,100,100, 'this text', /device
b = tvrd()
set_plot, entry_device
Note that the image was byte scaled since the Z-buffer is an 8-bit device.
Finally, you might get different character sizes in the Z-buffer compared to
a normal graphics window. To make sure the character sizes match, set the
character size explicitly in either case using a command like
device, set_character_size=[10, 12] ; width 10 pixels, height 12 pixels
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
|