"IndexedImagePanel"
Widget["IndexedImagePanel"]
represents an indexed image panel.
Details
- To use Widget["IndexedImagePanel"], you first need to load GUIKit using Needs["GUIKit`"].
- By default, the image is displayed centered and nonscaled in the panel; however, you can also allow the image to scale to fit the entire size of the panel.
- The following properties are available:
-
"imageWidth" 1 width of the image "imageHeight" 1 height of the image "imagePixelSize" 1 pixel size (an integer) "imageColorMapSize" 0 size of the color map "imageColorComponents" Null a list of the components of each color in the color map "imagePixels" Null the indices of each pixel "preferredSize" the display size of the image - The following event is available:
-
"mouseClicked" the event triggered when the mouse is clicked anywhere within the panel - The following method is available:
-
InvokeMethod["getImagePixelCoordinatesAt", mouseEvent] returns the image coordinates of the mouse event position - By default, most methods do not auto-repaint, so you can call a version of the methods taking True or False as the last argument. This allows you to make multiple calls to various locations on the image and then call InvokeMethod[{panel,"repaint"}] or a method with True as the last argument.
Examples
open allclose allBasic Examples (1)
Create a 5×5 image with five indexed colors, with all pixels set to black:
Loop 100 times, setting all pixels to random values:
Loop 100 times, setting a random cell in the first row to a random value within each loop:
Repaint the image to see the result:
Combine the previous two method calls by giving True as the last argument to "setImagePixel":
Loop 100 times, setting a random column to a random value:
Set the grid color to a custom value:
Scale the image to fit the size of the panel (after resizing):
Change the origin of the image:
The method "fillImagePixels" fills individual pixels of the image:
The method "fillImagePixelArray" fills an array of explicit locations:
It also fills a region given by an origin {x,y} value coupled with relative offset locations:
The method "fillImagePixelRect" fills a rectangular region:
With "setImagePixelRect", the region can be also be specified by its top-left location: