[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Object graphic and direct graphics



Hello,
I am using object graphics in a Direct graphic program because I need the 
alpha channel for some fancy image manupulation. Basically, I grab 
(TVRD(true=3)) the image from a direct graphic window, put it in an 
IDLgrImage, do some processing, draw it in a IDLgrBuffer, grab it from 
the buffer and TV it to the Direct graphic (Widget_draw). It work fine 
for most images but I recently discovered that some particular image 
dimensions induce a shift of the image (vertical and/or horizontal).
For me, image dimensions that are roughly multiples of 15 produce the 
problem.I wonder if there is a rational explanation for this behavior and 
if this can be reproduced on different system, with different IDL 
version.
I am using 5.2 on Win95.
Any comment greatly appreciated, I learn more from this newsgroup than 
from any documentation. At least until I buy DF's new book ;-)

Thomas Launey
Laboratory for Memory and Learning, Brain Science Institute, RIKEN
Saitama, JAPAN
e-mail: t_launey@brain.riken.go.jp



Below is a simple program that show this strange behavior 

   
;	NAME: Test_bug
;
;	PURPOSE: Test display problem when moving RGB data between
;	Object graphic (OG) and Direct graphics (DG)
;	RGB image is grabbed from a DG window, Drawn in IDLgrBuffer
;	Then grabbed from buffer and TV-ed back in the DG window.
;	Both the original and the grabbed image are displayed.
;
;	KEYWORDS: Xsize, Ysize: as it says
;		Verbose: display information about objects and RGB images
;   OBSERVATIONS:
;	For SOME image size, the image is shifted after each grab-paste.
;	This shift is observed for values Xsize and/or Ysize of
;	[13:15],30,60,[119:126],[238:241],480
;
;	IDL Version 5.2 (Win32 x86). Research Systems, Inc.


Pro Test_bug, Xsize=Xsize, ysize=ysize, verbose=verbose

Device, Get_Screen_Size=screenSize
If keyword_set(Xsize) then ImageXsize=Xsize>2 Else 
ImageXsize=ScreenSize[0]/10
If keyword_set(Ysize) then ImageYsize=Ysize>2 Else ImageYsize=ImageXsize

obuffer = OBJ_NEW('IDLgrBuffer', DIMENSIONS=[ImageXsize,ImageYsize], 
quality=2)
oview = OBJ_NEW('IDLgrView', viewplane_rect=[0,0,ImageXsize,ImageYsize],$
	dimensions=[ImageXsize,ImageYsize])
omodel = OBJ_NEW('IDLgrModel')
oimage = OBJ_NEW('IDLgrImage', INTERLEAVE=2)
omodel -> Add, oimage
oview -> Add, omodel
oContainer = Obj_New('IDL_Container')
oContainer->Add, oBuffer
oContainer->Add, oView
oContainer->Add, oModel
oContainer->Add, oimage

loadct,5, /silent	; give some color to the image
savewin=!D.window
Window, /free, xsize=ImageXsize, ysize=ImageYsize, title="original image"
image= BESELJ(SHIFT(DIST(ImageXsize), ImageXsize/2, $
		ImageYsize/2)/2, 0)*256
TV, image
Window, /free, xsize=ImageXsize, ysize=ImageYsize, title="test window"
testwin=!d.window
TV, image
Direct_grabbed = TVRD(true=3)
;*** load the grayscale LUT, otherwise strange things happen when TV-ing 
; the RGB image.
loadct,0, /silent
For i=0,30 do Begin
	;*** set grabbed image as the data in oimage
	oimage   -> SetProperty,  data=Direct_grabbed
	oBuffer -> Draw, oview	;*** Draw image into oBuffer
	;*** grab image from the graphic buffer object
	oBuffer -> GetProperty, image_data=Object_grabbed
	;*** true=1 since Object_grabbed is [3,Xsize,Ysize]
	tv, Object_grabbed, true=1	
	;*** grab image from the direct grahic window
	Direct_grabbed = TVRD(true=3)
EndFor

If keyword_set(verbose) then begin
	Help, Direct_grabbed
	Help, Object_grabbed
	oview -> GetProperty, All=all
	 Print, string(10B), "IDLgrView properties"
	 print, "dimensions: " ,all.dimensions
	 print, "location: " ,all.location
	 print, "view_rect: ",all.VIEWPLANE_RECT,string(10B)
	obuffer -> GetProperty, All=all
	 Print, "IDLgrbuffer properties"
	 print, "dimensions: " ,all.dimensions
	 print, "screen dim: " ,all.SCREEN_DIMENSIONS
	 print, "resolution: ",all.resolution
EndIf
obj_destroy, oContainer
wset, savewin
End