Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

SETPIXELSRGB

Graphics Subroutine: Sets multiple pixels to the given Red-Green-Blue (RGB) color. This routine is only available for Windows.

Module

USE IFQWIN

CALL SETPIXELSRGB (n,x,y,color)

n

(Input) INTEGER(4). Number of pixels to be changed. Determines the number of elements in arrays x and y.

x, y

(Input) INTEGER(2). Parallel arrays containing viewport coordinates of the pixels to set.

color

(Input) INTEGER(4). Array containing the RGB color values to set the pixels to. Range and result depend on the system's display adapter.

SETPIXELSRGB sets the pixels specified in the arrays x and y to the RGB color values in color. These arrays are parallel: the first element in each of the three arrays refers to a single pixel, the second element refers to the next pixel, and so on.

In each RGB color value, each of the three color values, red, green, and blue, is represented by an eight-bit value (2 hex digits). In the value you set with SETPIXELSRGB, red is the rightmost byte, followed by green and blue. The RGB value's internal structure is as follows:

Larger numbers correspond to stronger color intensity with binary 1111111 (hex Z'FF') the maximum for each of the three components. For example, Z'0000FF' yields full-intensity red, Z'00FF00' full-intensity green, Z'FF0000' full-intensity blue, and Z'FFFFFF' full-intensity for all three, resulting in bright white.

A good use for SETPIXELSRGB is as a buffering form of SETPIXELRGB, which can improve performance substantially. The example code shows how to do this.

If any of the pixels are outside the clipping region, those pixels are ignored. Calls to SETPIXELSRGB with n less than 1 are also ignored.

SETPIXELSRGB (and the other RGB color selection functions such as SETPIXELRGB and SETCOLORRGB) sets colors to values chosen from the entire available range. The non-RGB color functions (such as SETPIXELS and SETCOLOR) use color indexes rather than true color values.

If you use color indexes, you are restricted to the colors available in the palette, at most 256. Some display adapters (SVGA and true color) are capable of creating 262,144 (256K) colors or more. To access any available color, you need to specify an explicit RGB value with an RGB color function, rather than a palette index with a non-RGB color function.

Example

 ! Buffering replacement for SetPixelRGB and
 ! SetPixelRGB_W. This can improve performance by
 ! doing batches of pixels together.

 USE IFQWIN
 PARAMETER (I$SIZE = 200)
 INTEGER(4) bn, bc(I$SIZE), status
 INTEGER(2) bx(I$SIZE),by(I$SIZE)

 bn = 0
 DO i = 1, I$SIZE
   bn = bn + 1
   bx(bn) = i
   by(bn) = i
   bc(bn) = GETCOLORRGB()
   status = SETCOLORRGB(bc(bn)+1)
 END DO
 CALL SETPIXELSRGB(bn,bx,by,bc)
 END