Loading

Pimage

processing

The Pimage function draws a Pimage (see Pdecode) on a PGraphic object.

The img parameter specifies the image to display and by default the a and b parameters define the location of its upper-left corner. The image is displayed at its original size unless the c and d parameters specify a different size. The PimageMode function can be used to change the way these parameters draw the image.

The color of an image may be modified with the Ptint function. This function will maintain transparency for GIF and PNG images.

Link to original Processing doc

Pimage is available since version 1.0.0.

See also

Signature

Examples

// @preview image 200 100 '2D' PGraphics DUP 'Pg' STORE //new 200x100 image 0xffffffff Pbackground //white background 'CENTER' PimageMode //set Pimage mode to centered //load a klingon salute png "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAABggAAAYIBFx04PQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAMkSURBVFiFrddNqFVVFAfwn/oSv0jtKZqPkiZiHyRpIWka2ixpUpBBhZhgg2jwBk0cFCES4SCIHFQDBbWocBDiwFLoKUWDBBE0sYwSeoZlPTV86ktvg7UPd3veve/ec+/7w2GfdfZee/3PXmuvtTdjYwnWYGqDvqdxEpfwOea0mKsSJuFT1NJzAcuy/kUYxtd4C39hP1ZhA+7rlsDzyfArYhWO4/usvx/X1Ffm9YxsDdexvhsCW3E+kzekiRckeTvOZf2bUv+r6MU+sSoTWxlqNuBXzMPcJA+kdnVqZ2EoGz8LN/AxLmJvIjK/EwJLRAxMED4tCJ1rQWAIt5I8PbXDVQhMxpfC3x+mb6uz/oFMnt2EQC7fwuUqBF7CM3gRj4gt9mTWfwQPCLeUDTYidAU3qxB4EL/gE7EKO/BwmqwgULilmQtyQv+0Ml4mcBF9wv9wNPU/keQzGBRumI2/SwbLcmUCpzEF9yb5pEhAeRwcFW6ZKTJggUYrUpnAj6m9P7U1fGt0HBS7pGywTKiQF+AAroqffLYZgZ8xgsXZtwEsxYxMnpDeW+2CodR+I2JpK87iM1la78mURtKAnMCRNGYFvsIpkeHmZAYnY1oDApewWySj5WKFe0QcPYdj5RUgligncCJNXLihlv4I/siMMXoXrMc6bFR37zQRZ1c1wTsi8HLsx8FMXogXMvkO7MI9SZ4k9n8N75bmek8UsabVsig6vdm3xeopuR3cmeY4pL6lieAdwdtjKS9PyisrGGyEjbgrkyfiOxHoU8ZSLNhv6pJAGZvTvOvaGTwo6v14oRd/imNbWzgsAm+8sFNUxb52FT4Q+WA8sEqU5f4qSi+7/fjVKXpEVT0htmrb6MN/4qDZDd4Q+eDxTpT3ibNBo/tAO1iIf/FRh/oeEhnr/Q50p+IH/O72XFAZ/SIWtlTQmS5W74b6QaYrbEskvtA6KB8V1XJYl5eSMs4mEtewRxxal4nr2VN4TaTZ4la0djyNw0/J8JvpvVZ6booSXdwl5zacpQl6Wg8Bd4vDyXaxTReJonIev4nz32NVDFfBAaP/utkzqEW1K+N/QkDNWuXUcakAAAAASUVORK5CYII=" Pdecode DUP 'Pimg' STORE //decode it 100 50 Pimage //paste it in the middle of the image Pencode //render $Pg TYPEOF //display type of object $Pimg TYPEOF //display type of object
// @preview image 200 100 '2D' PGraphics DUP 'Pg' STORE //new 200x100 image 0xffffff80 Pbackground //yellow background 'CENTER' PimageMode //set Pimage mode to centered //load a klingon salute png "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAABggAAAYIBFx04PQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAMkSURBVFiFrddNqFVVFAfwn/oSv0jtKZqPkiZiHyRpIWka2ixpUpBBhZhgg2jwBk0cFCES4SCIHFQDBbWocBDiwFLoKUWDBBE0sYwSeoZlPTV86ktvg7UPd3veve/ec+/7w2GfdfZee/3PXmuvtTdjYwnWYGqDvqdxEpfwOea0mKsSJuFT1NJzAcuy/kUYxtd4C39hP1ZhA+7rlsDzyfArYhWO4/usvx/X1Ffm9YxsDdexvhsCW3E+kzekiRckeTvOZf2bUv+r6MU+sSoTWxlqNuBXzMPcJA+kdnVqZ2EoGz8LN/AxLmJvIjK/EwJLRAxMED4tCJ1rQWAIt5I8PbXDVQhMxpfC3x+mb6uz/oFMnt2EQC7fwuUqBF7CM3gRj4gt9mTWfwQPCLeUDTYidAU3qxB4EL/gE7EKO/BwmqwgULilmQtyQv+0Ml4mcBF9wv9wNPU/keQzGBRumI2/SwbLcmUCpzEF9yb5pEhAeRwcFW6ZKTJggUYrUpnAj6m9P7U1fGt0HBS7pGywTKiQF+AAroqffLYZgZ8xgsXZtwEsxYxMnpDeW+2CodR+I2JpK87iM1la78mURtKAnMCRNGYFvsIpkeHmZAYnY1oDApewWySj5WKFe0QcPYdj5RUgligncCJNXLihlv4I/siMMXoXrMc6bFR37zQRZ1c1wTsi8HLsx8FMXogXMvkO7MI9SZ4k9n8N75bmek8UsabVsig6vdm3xeopuR3cmeY4pL6lieAdwdtjKS9PyisrGGyEjbgrkyfiOxHoU8ZSLNhv6pJAGZvTvOvaGTwo6v14oRd/imNbWzgsAm+8sFNUxb52FT4Q+WA8sEqU5f4qSi+7/fjVKXpEVT0htmrb6MN/4qDZDd4Q+eDxTpT3ibNBo/tAO1iIf/FRh/oeEhnr/Q50p+IH/O72XFAZ/SIWtlTQmS5W74b6QaYrbEskvtA6KB8V1XJYl5eSMs4mEtewRxxal4nr2VN4TaTZ4la0djyNw0/J8JvpvVZ6booSXdwl5zacpQl6Wg8Bd4vDyXaxTReJonIev4nz32NVDFfBAaP/utkzqEW1K+N/QkDNWuXUcakAAAAASUVORK5CYII=" Pdecode DUP 'Pimg' STORE //decode it 100 50 150 100 Pimage //paste it in the middle of the image, constrain size to 150x100 Pencode //render $Pg TYPEOF //display type of object $Pimg TYPEOF //display type of object