Table of Contents Glide Programming Guide


Example Accessing the Linear Frame Buffer.1 Reading a pixel value from the LFB



Download 6.22 Mb.
Page83/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   79   80   81   82   83   84   85   86   ...   106
GLIDEPGM
Example Accessing the Linear Frame Buffer.1 Reading a pixel value from the LFB.
The following code segment reads 10 pixels from the color buffer currently being displayed, starting with the pixel at (100, 200), and stores them in the pix[] array. The read pointer is initially set to the value returned in the info structure when the lock was initiated. A byte offset representing (100, 200) is calculated, converted to a word address, and added to the initial value to produce the starting address. The writeMode, origin, and pixelPipeline arguments to grLfbLock() are ignored for read-only pointers.
#define BYTESPERPIXEL 2

FxU16 pix[10];


GrLfbInfo_t info;
FxU32 *rptr;
int i;

/* get a read pointer */


if ( grLfbLock( GR_LFB_READ_ONLY, GR_LFB_FRONTBUFFER, GR_LFB_WRITEMODE_ANY,
GR_ORIGIN_ANY, FXFALSE, &info)) {

/* add in the word address of the first pixel */


/* (compute byte offset for (100,200)/4 */
rptr = info.lfbPtr
rptr += ((*info.strideInBytes * 200) + 100*BYTESPERPIXEL)>>2;

/*read two pixels at a time */


for (i=0; i<10; rptr++) {
pix[i++] = *rptr && 0xFFFF;
pix[i++] = *rptr >>16;
}
grLfbUnlock( GR_LFB_READ_ONLY, GR_LFB_FRONTBUFFER );
}

5Reading a Rectangle of Pixels from the LFB


The grLfbReadRegion() convenience function copies a rectangle of pixels from the frame buffer to user memory as efficiently as possible, performing the buffer locks and unlocks as needed. Note that this is the only way to read back from the frame buffer on Scanline Interleaved systems.
FxBool grLfbReadRegion( GrBuffer_t src_buffer,
FxU32 src_x,
FxU32 src_y,
FxU32 src_width,
FxU32 src_height,
FxU32 dst_stride,
void *dst_data
)
A src_width by src_height rectangle of pixels is copied from the buffer specified by src_buffer, starting at the location (src_x, src_y). The pixels are copied to user memory starting at dst_data, with a stride in bytes defined by dst_stride. The frame buffer y origin is always assumed to be at the upper left and the pixel data format is assumed to be GR_LFBWRITEMODE_565 (see Table Accessing the Linear Frame Buffer.2). The dst_stride must be greater than or equal to src_width * 2.

Download 6.22 Mb.

Share with your friends:
1   ...   79   80   81   82   83   84   85   86   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page