GUIKit`
GUIKit`

"IndexedImagePanel"

The functionality provided by GUIKit has been superseded by the interface construction and controls functions native to the built-in Wolfram Language.

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"1width of the image
    "imageHeight"1height of the image
    "imagePixelSize"1pixel size (an integer)
    "imageColorMapSize"0size of the color map
    "imageColorComponents"Nulla list of the components of each color in the color map
    "imagePixels"Nullthe 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 all

Basic Examples  (1)

Create a 5×5 image with five indexed colors, with all pixels set to black:

Set all pixels to white:

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:

Display the grid:

Set the grid color to a custom value:

Scale the image to fit the size of the panel (after resizing):

Preserve the aspect ratio:

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:

Interactive Examples  (2)

Create an image in which each cell is filled with a random color when clicked:

After several clicks:

Create a three-color image panel in which clicking a gray square turns it black and subsequent clicks toggle between white and black:

After a few random clicks and reclicks: