IupImage

IUP - Portable User Interface

IupImage

Creates an image to be shown on a label, button, toggle, or as a cursor.

Parameters/Return

Ihandle* IupImage(int width, int height, char *pixels); [in C]
iupimage{pixels: table of numbers, colors: table of colors} -> (elem: iuplua_tag) [in IupLua3]
iup.image{pixels: table of numbers, colors: table of colors} -> (elem: iuplua_tag) [in IupLua5]
image(width, height, b1, b2, ...) [in LED]

width: Image width in pixels.
height: Image height in pixels.
pixels: Vector containing the color of each pixel.
b1, b2, ...: Color index of the pixels.

This function returns the identifier of the created image, or NULL (nil in IupLua) if an error occurs.

Attributes

"0" Color in index 0.
"1" Color in index 1.
...
"i" Color in index i.

The indices can range from 0 to 255. The total number of colors is limited to 256 colors. Notice that in Lua the first index in the array is "1", the index "0" is ignored in IupLua. Be careful when setting colors, since they are attributes they follow the same storage rules for standard attributes.

The values are integer numbers from 0 to 255, one for each color in the RGB standard ("255 255 255"). If the value of a given index is "BGCOLOR", the color used will be the background color of the element on which the image will be inserted. The "BGCOLOR" must be defined with an index less than 16.

HOTSPOT: The hotspot (x:y coordinates) used to define cursors.

HEIGHT: Image height.

WIDTH: Image width.

Notes

An image created with IupImage can be reused for different buttons and labels. But in Motif the BGCOLOR color index will be calculated only once when it is first used.

The images must be destroyed when they are no longer necessary, by means of the IupDestroy function. To destroy an image, it cannot be in use. Please observe the rules for creating cursor images: CURSOR.

The pixels array is duplicated internally so you can discart it after calling IupImage.

If do not set a colors it is used a default color for the 16 first colors. The default color table is the same for Windows and Motif:

 0 =   0,  0,  0 (black)
 1 = 128,  0,  0 (dark red)
 2 =   0,128,  0 (dark green) 
 3 = 128,128,  0 (dark yellow)
 4 =   0,  0,128 (dark blue)
 5 = 128,  0,128 (dark magenta) 
 6 =   0,128,128 (dark cian) 
 7 = 192,192,192 (gray)
 8 = 128,128,128 (dark gray)
 9 = 255,  0,  0 (red)     
10 =   0,255,  0 (green)
11 = 255,255,  0 (yellow)
12 =   0,  0,255 (blue)
13 = 255,  0,255 (magenta)
14 =   0,255,255 (cian)  
15 = 255,255,255 (white)

For images with more than 16 colors, all the color indices must be defined up to the maximum number of colors. For example, if the biggest image index is 100, then all the colors from i=16 up to i=100 must be defined even if some indices are not used. Note that to use more than 128 colors you must use an "unsigned char*" pointer and simply cast it to "char*" when calling the IupImage function.

The EdPatt and the IMLAB applications can load and save images in LED format. They allow operations such as importing GIF images and exporting them as IUP images. EdPatt allows you to manually edit the images, and also have support for imagens in IupLua.

You can donwload several IUP images in LED format from iup_images.zip. To view the images you can use the LED viewer application, see IupView in the applications included in the distribution.

Application icons are usually 32x32. Toolbar bitmaps are 24x24. Menu bitmaps and small icons are 16x16.

Examples

See Also

IupLabel, IupButton, IupToggle.