; docformat = 'rst' ;+ ; Demo MG_TILEJP2 on ohare.jp2 JPEG2000 image. This routine will construct the ; JPEG2000 file if not in the current directory. There will be a delay if this ; is necessary. ; ; :Keywords: ; renderer : in, optional, type=long ; set to 0 for hardware rendering, 1 for software rendering ;- pro mg_tilejp2_demo, renderer=renderer compile_opt strictarr jp2filename = 'ohare.jp2' ; check if ohare.jp2 is present, create if not present if (~file_test(jp2Filename)) then begin jpegFilename = filepath('ohare.jpg', $ subdirectory=['examples', 'data']) read_jpeg, jpegFilename, jpegImage imageDims = size(jpegImage, /dimensions) ; create the JPEG2000 image object jp2 = obj_new('IDLffJPEG2000', jp2Filename, write=1) jp2->setProperty, n_components=3, $ n_layers=20, $ n_levels=6, $ offset=[0, 0], $ tile_dimensions=[1024, 1024], $ tile_offset=[0, 0], $ bit_depth=[8, 8, 8], $ dimensions=[imageDims[1], imageDims[2]] ; Set image data, and then destroy the object. You must create ; and close the JPEG2000 file object before you can access the ; data. jp2->setData, jpegImage obj_destroy, jp2 endif ; start mg_tilejp2 mg_tilejp2, jp2Filename, renderer=renderer end