Updating direct draw

Posted by / 11-Jun-2020 11:50

Updating direct draw

But most of todays CPU offer instructions for mass operations like MOVS, STOS for x86 architecture.Pixel size should be 1, 2 or 4 bytes to be able to use this optimization.Standard graphical LCL components provides Canvas object for common drawing.But most of available graphic routines have some overhead given by universality, platform independence and safety.

Then calculation of pixel position is matter of fetching pointer for rows and add horizontal position to it.If code is notably smaller like Set Pixel and Get Pixel methods it is better to inline instructions rather than do push and pop operations on stact with execution of call and ret instruction.This optimization will be even significant if such operation is executed many times as pixel operations do.But this would require calling Create and Destroy for each pixel instance and further background processing caused by allocation and deallocation memory on a heap.Notable implementation of the pixel type is Graphics32 library which define pixel using composed record type with case construction to union access with different methods to the same pixel data.

updating direct draw-40updating direct draw-37updating direct draw-33

Position of pixels have to be calculated by using equation Y * Width X with use of instructions for addition and multiplication.