|
|
|
|
|
dImageToArray (Function) In french: dImageVersTableau Copies the RGB pixels of the image into a one-dimensional or two-dimensional array. The array of colors is cleared then it is filled with the integers representing the colors (24 bits) of the image.
tabLuminance is array of * by * int
dImageToArray("c:\test.png", tabLuminance, dComponentRed + dGrayScale)
dStartDrawing(IMG_SansNom2)
nx, ny are int
FOR nx = 1 _TO_ ArrayInfo(tabLuminance, tiNumberRows)
FOR ny = 1 _TO_ ArrayInfo(tabLuminance, tiNumberColumns)
dPoint(nx-1, ny-1, tabLuminance[nx][ny])
END
END
Syntax
Copying the pixels of an image file into an array Hide the details
dImageToArray(<Image file> , <Array> [, <Options>])
<Image file>: Character string Path of image file to use. <Array>: Array variable Name of the array of 24-bit color into which the pixels will be copied. This array can be a one-dimensional array or a two-dimensional array. For a two-dimensional array, the dimensions represent the X and Y axes of the image. <Options>: Optional Integer constant (or combination of constants) Options for calculating the array: | | dComponentBlue | The Blue component of image will be copied into the array. | dComponentGreen | The Green component of image will be copied into the array. | dComponentRed | The Red component of image will be copied into the array. | dComponentRGB | All image components will be copied into the array. | dGrayScale | The image in grayscale will be copied into the array. |
Copying the pixels of an image in memory into an array Hide the details
dImageToArray(<Image in memory> , <Array> [, <Options>])
<Image in memory>: Buffer or character string Byte string containing the image to use. This parameter can correspond to an image saved in memory (dSaveImageBMP, dSaveImageGIF, etc.). <Array>: Array variable Name of the array of 24-bit color into which the pixels will be copied. This array can be a one-dimensional array or a two-dimensional array. For a two-dimensional array, the dimensions represent the X and Y axes of the image. <Options>: Optional Integer constant (or combination of constants) Options for calculating the array: | | dComponentBlue | The Blue component of image will be copied into the array. | dComponentGreen | The Green component of image will be copied into the array. | dComponentRed | The Red component of image will be copied into the array. | dComponentRGB | All image components will be copied into the array. | dGrayScale | The image in grayscale will be copied into the array. |
Remarks - The alpha channel of the image is not returned by this function.
- Behavior change in version 23 When converting a PDF file (i.e. a vector image) into an array of pixels, a conversion factor must be applied to transform a PDF unit into a pixel.
From version 23 onwards, the conversion factor has been optimized, which results in a reduction in the size of the image in pixels. To go back to the behavior of version 22 (non-optimized), you can use the following code (this code uses an Image variable to convert the PDF into the desired dimensions):
lCMonImageh is string = fCurrentDir() + ["\"] + "monfichier.pdf"
iiMage is Image = dLoadImage(lCMonImageh, imgConvert, 2479, 3504)
bufImage is Buffer = dSaveImagePNG(iiMage, inMemory)
lTableauPixelSource is array of * by * int
dImageToArray(bufImage, lTableauPixelSource, dComponentRGB + dGrayScale)
Trace(ArrayInfo(lTableauPixelSource, tiNumberRows) + TAB + ...
ArrayInfo(lTableauPixelSource, tiNumberColumns))
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|