X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



3785 Rate this article:
No rating

IDL 8.2: Change in behavior when using 3-D arrays for button icons on Windows

IDL widget buttons can be labeled using images. To do this, you can provide the WIDGET_BUTTON function with a bitmap file, a 4-D array, or a 3-D array.  In IDL 8.2, the behavior of the WIDGET_BUTTON function has changed when a 3-D array is used to generate the label on Windows systems. For example, in IDL 8.1, you can enter in the following code into IDL and it will create a button that has three boxes (colored red, green and blue) on  a black background:

test_img = BYTARR(100,100,3)
test_img[25:50,25:50,1]=255
test_img[0:25,0:25,0]=255
test_img[50:75,50:75,2]=255

base=WIDGET_BASE() ;create the widget base
button=WIDGET_BUTTON(base,VALUE=test_img)  ;create the widget button
widget_control,base,/REALIZE

However, If you are using IDL 8.2 on Windows, you will notice that the box in the bottom left corner is colored grey (it should be colored red).

IDL 8.1 (correct color)                   

 Caption: Left picture: button as it would appear in IDL8.1 (the color is correct).
Right picture: button as it appear in IDL 8.2 (bottom corner grayed out).

There are three methods you could use to get the color to display correctly:

1) You can set the MASK keyword with the WIDGET_BUTTON to zero. By default the Mask keyword of the WIDGET_BUTTON is set to 1. On Windows, this makes the pixel value in the bottom left-hand corner of the image transparent. If you set MASK=0, it removes the gray from the image:

base=WIDGET_BASE() ;create the widget base
button=WIDGET_BUTTON(base,VALUE=test_img, MASK=0)  ;create the widget button
widget_control,base,/REALIZE

2) Change the value in the lower left pixel to a color that is not used anywhere else in the image. For example, you could add the "test_img[ 0, 0, 0 ] = 254" before creating the button in the example code.

3) You can convert the 3-D array (RGB) to a 4-D array (RGBA) with the alpha values all set to 255. For example:


test_img = BYTARR(100,100,3)
test_img[25:50,25:50,1]=255
test_img[0:25,0:25,0]=255
test_img[50:75,50:75,2]=255


;get the version information

vers = !version.RELEASE
vers = float(vers)


if (vers gt 8.1) then begin ;check if version is IDL 8.2


     temp_img=BYTARR(100,100,4)
     temp_img[0,0,0]=test_img
     temp_img[*,*,3]=255
     test_img=temp_img

endif



base=WIDGET_BASE() ;create the widget base

button=WIDGET_BUTTON(base,VALUE=test_img)  ;create the widget button
widget_control,base,/REALIZE

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »