GUIKIT PACKAGE
{}

"IndexedImagePanel"

Widget["IndexedImagePanel"]
represents an indexed image panel.

DetailsDetails

  • 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.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

In[1]:=
Click for copyable input

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

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Set all pixels to white:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=

Loop 100 times, setting all pixels to random values:

In[6]:=
Click for copyable input
In[7]:=
Click for copyable input
Out[7]=

Loop 100 times, setting a random cell in the first row to a random value within each loop:

In[8]:=
Click for copyable input
In[9]:=
Click for copyable input
Out[9]=

Repaint the image to see the result:

In[10]:=
Click for copyable input
In[11]:=
Click for copyable input
Out[11]=

Combine the previous two method calls by giving True as the last argument to :

In[12]:=
Click for copyable input
In[13]:=
Click for copyable input
Out[13]=

Loop 100 times, setting a random column to a random value:

In[14]:=
Click for copyable input
In[15]:=
Click for copyable input
Out[15]=

Display the grid:

In[16]:=
Click for copyable input
In[17]:=
Click for copyable input
In[18]:=
Click for copyable input
Out[18]=

Set the grid color to a custom value:

In[19]:=
Click for copyable input
In[20]:=
Click for copyable input
In[21]:=
Click for copyable input
Out[21]=

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

In[22]:=
Click for copyable input
In[23]:=
Click for copyable input
In[24]:=
Click for copyable input
Out[24]=

Preserve the aspect ratio:

In[25]:=
Click for copyable input
In[26]:=
Click for copyable input
In[27]:=
Click for copyable input
Out[27]=

Change the origin of the image:

In[28]:=
Click for copyable input
In[29]:=
Click for copyable input
In[30]:=
Click for copyable input
Out[30]=

The method fills individual pixels of the image:

In[31]:=
Click for copyable input
In[32]:=
Click for copyable input
Out[32]=

The method fills an array of explicit locations:

In[33]:=
Click for copyable input
In[34]:=
Click for copyable input
Out[34]=

It also fills a region given by an origin value coupled with relative offset locations:

In[35]:=
Click for copyable input
In[36]:=
Click for copyable input
Out[36]=
In[37]:=
Click for copyable input
In[38]:=
Click for copyable input
Out[38]=

The method fills a rectangular region:

In[39]:=
Click for copyable input
In[40]:=
Click for copyable input
Out[40]=

With , the region can be also be specified by its top-left location:

In[41]:=
Click for copyable input
In[42]:=
Click for copyable input
Out[42]=