X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 13 Dec 2005 11:12 PM by  anon
how to allocate more memory?
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
13 Dec 2005 11:12 PM
    I am trying to display grayscale images in a scroll widget that are about 38,000 pixels long and 1,000 wide, and IDL doesn't have the memory to do it. The exact error is this: WIDGET_CONTROL: Unable to create X windows pixmap (BadAlloc (insufficient resources for operation)). Please tell me there's a way to allocate more memory to do this! Thanks, Chris Jackolski

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Dec 2005 11:12 PM
    Chris, Your problem is not conventional process memory; it is a problem of restrictions that Windowing systems put on the maximum size of "pixmap" that it is willing to buffer to support refreshing the pixel values of large images. In IDL Direct Graphics, this max dimension might vary with the video card memory size, but I know that in IDL Object Graphics the max memory is more part of fairly standardized restrictions in the OpenGL libraries rather than hardware-defined memory standards. No matter, though; one of the workarounds is the same no matter what is forcing the restriction, and no matter whether you are programming in IDL Direct Graphics or IDL Object Graphics. That workaround is an algorithm based on WIDGET_DRAW's '/APP_SCROLL' keyword setting. The example below demonstrates, while IDL's Online Help for that APP_SCROLL keyword discusses its principles: ; File: 'big_image_app_scroll_ex.pro' ; Syntax: BIG_IMAGE_APP_SCROLL_EX ; Purpose: Demonstrate how WIDGET_DRAW's APP_SCROLL can be used ; to display an oversized image in a scrollable WIDGET_DRAW. By ; oversized we mean images with a dimension greater than 2048 pixels, ; a limit imposed by OpenGL for max window/pixmap size. The example ; used here is an 864 x 2592 image. ; Just a stub PRO big_image_app_scroll_ex_event, ev print, ev END ; Event handler for the WIDGET_DRAW PRO wdraw_event, event ; Case of viewport event if event.type eq 3 then begin widget_control, event.id, GET_VALUE=oWindow ; By using 'geom' we can deal with viewport resizes, should ; you be implementing those. geom = widget_info(event.id, /GEOMETRY) viewW = geom.xsize GetProperty, GRAPHICS_TREE=oView oView->SetProperty, $ VIEWPLANE_RECT=[event.x, event.y, viewW, viewH] oWindow->Draw endif END ; Widget Creation routine PRO big_image_app_scroll_ex ;make a big image to display (8641 X 2592) xs=864L ys=3*864L img1=dist(xs) img=fltarr(xs,ys) img[0,0]=img1 img[0,xs]=shift(img1,200,200) img[0,xs*2]=shift(img1,400,400) ; Initial viewport size viewW = 400 viewH = 400 tlb = widget_base(/COLUMN) ; APP_SCROLL allows XSIZE and YSIZE to take any large dimension ; without violating any widget system limits. wDraw = widget_draw(tlb, XSIZE=xs, YSIZE=ys, GRAPHICS_LEVEL=2, $ X_SCROLL_SIZE=viewW, Y_SCROLL_SIZE=viewH, /APP_SCROLL, $ /VIEWPORT_EVENTS, EVENT_PRO='wdraw_event') widget_control, tlb, /REALIZE widget_control, wDraw, GET_VALUE=oWindow oImg = obj_new('IDLgrImage', img, ORDER=1) oModel = obj_new('IDLgrModel') oView = obj_new('IDLgrView', PROJECTION=1, EYE=3., $ VIEWPLANE_RECT=[0,0,viewW,viewH], COLOR=[0,0,0]) oModel->Add, oImg oView->Add, oModel ; Using the GRAPHICS_TREE was an alternative way of passing all ; the object states to the event handler. oWindow->SetProperty, GRAPHICS_TREE=oView oWindow->Draw, oView xmanager, 'big_image_app_scroll_ex', tlb END Since IDL 6.2, the Object Graphics IDLgrImage Class has some new TILING properties and methods that are also very useful for the kind of problem you are encountering, Chris, but the algorithms are a little more complicated. Look up in Online Help the index topic IDLgrImage::SetTileData and follow its 'Image Tiling' link, if you are working with IDL Object Graphics and want to check out an alternative algorithm. James Jones
    You are not authorized to post a reply.