Question:
When using a canvas, the return value from the pixels
property returns an invalid color of -1 or hex $FFFFFFFF.
How can I get around this?
Answer:
This can happen if the requested pixel is not in the
current clipping region. This can also happen on devices
that do not support the Windows API functions GetPixel()
and SetPixel(). You should check the return value from
the GetDeviceCaps() to check to see if a device supports
raster operations before using these functions. A printer
and/or metafile canvas is a likley candidate for a device
that the pixels property may fail on.
Example:
if (GetDeviceCaps(Printer.Canvas.Handle, RASTERCAPS)
and RC_NONE) = RC_NONE then
NoRasterOperations := True;