AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Controles, páginas y ventanas / Funciones de dibujo
  • Identifying the color of a pixel
dPixelColor (Example)
Identifying the color of a pixel
The following code shows how to identify the color of a pixel. The user clicks the image control (IMG_ImageDrawing) to select the pixel. The coordinates of the selected pixel can be retrieved with MouseXPos and MouseYPos.
In this example, we will assume that the image control (IMG_ImageDrawing) contains one image.
// -- Click code of "IMG_ImageDrawing"
 
// Declare the variables
PixelColor is int
CoordHorPixel is int
CoordVertPixel is int
PixelColorRed is int
PixelColorGreen is int
PixelColorBlue is int
 
// Retrieve the coordinates of the selected pixel
CoordHorPixel = MouseXPos()
CoordVertPixel = MouseYPos()
 
// Identify the color of the selected pixel
PixelColor = dPixelColor(IMG_ImageDrawing, CoordHorPixel, CoordVertPixel)
PixelColorRed = modulo(PixelColor, 256)
PixelColorGreen = modulo(PixelColor/256, 256)
PixelColorBlue = modulo(PixelColor/256/256, 256)
 
// Display the result
Info("The color components of the pixel are: " + CR + ...
TAB + "- Red: " + PixelColorRed + CR + ...
TAB + "- Green: " + PixelColorGreen + CR + ...
TAB + "- Blue: " + PixelColorBlue)
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/05/2022

Señalar un error o enviar una sugerencia | Ayuda local