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.



7386 Rate this article:
No rating

IDL 8.2: 32-bit (RGBA) bitmap images are now supported

In IDL 8.2, 32-bit (RGBA) bitmap (.bmp) files can now be used to create image labels for buttons. This allows you to easily use RGBA files created using IDL 8.2 or graphic programs such as PhotoShop image labels.

Opening and displaying an RGBA bitmap file

Each pixel in an RGBA image has 4 byte values associated with it. The RGB (Red, Green and Blue) values describe the color of the pixel. The A (alpha) value describes the transparency of the pixel. A pixel with an alpha value of 255  has zero transparency (completely opaque).  An example RGBA bitmap file is attached below (right click on the image, select "Save image as" and save it as 'btmap_alpha_ex.bmp" in your IDL path ):

 

 The first thing that you might notice if you use READ_BMP to read the image, and display it, is that the Red and Blue colors have been switched.  For example:

file = file_which('btmap_alpha_ex.bmp')
t_img = READ_BMP(file)
i = image(t_img, TITLE='Color wrong', LAYOUT=[2,1,1])

 

 


 This occurs because .bmp files store images in the order of BGR. To get around this issue, you can use the RGB keyword with READ_BMP.  

file = file_which('btmap_alpha_ex.bmp')
t_img2 = READ_BMP(file, /RGB)
i2 = image(t_img2, TITLE='Color correct /RGB',/CURRENT, LAYOUT=[2,1,2])

 


 

Using an RGBA bitmap file for button label

 

To specify an image file as a button label, you can use the VALUE and BITMAP keyword. This can seen below:

file = file_which('btmap_alpha_ex.bmp')
base=WIDGET_BASE() ;create the widget base
button=WIDGET_BUTTON(base,VALUE=file,/BITMAP)  ;create the widget button
widget_control,base,/REALIZE

 

Using a 4-D array for button label

 To use a 4-D array to generate a button, you must provide the WIDGET_BUTTON with a [n,m,4] array using the VALUE keyword.  The example shown below should produce the same image on the button as the image in the previous section.

file = file_which('btmap_alpha_ex.bmp')
t_img2 = READ_BMP(file, /RGB) 
button_img = transpose(t_img2, [1,2,0])
 
base2=WIDGET_BASE()
button2=WIDGET_BUTTON(base2,VALUE=button_img)
widget_control,base2,/REALIZE

Writing an RGBA file

In IDL 8.2,  the WRITE_BMP function now supports 32-bit bitmap files. Therefore you can now  use this function to write 4-D arrays to bitmap files. An example is shown below (notice the interleaving of the array being  written the file is [4,n,m]). 

temp_img=BYTARR(4,100,100)

temp_img[1,25:50,25:50]=255

temp_img[0,0:25,0:25]=255

temp_img[2,50:75,50:75]=255
temp_img[3,*,*]=100
 
WRITE_BMP,"ex_transparent_file.bmp",temp_img


Reviewed by DS 9/17/2014

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 »