2004. december 17., péntek
How to copy a 2D array with picture greylevels to an image
Problem/Question/Abstract:
I want to move a 2D array with picture grey-levels to an Image or BMP object without first save the array to disk? I want to display the image faster on the canvas than I do now by using canvas.pixels.
Answer:
A solution (not necessarily the best but it works) is as follows:
1. Create a Bitmap (TBitmap) within the TImage
Bitmap := TBitmap.Create;
BitMap.Width := NCol;
BitMap.Height := NRow;
{...}
2. Create a logical palette (greyscale or whatever) and assign it to Bitmap.Palette
CreatePalette(MyLogPalette);
{ etc. }
3. Now draw pixels into the Bitmap canvas NOT the image canvas (which is slow...). Use the
number of colours in your logical palette to scale the intensity values.
4. Clean up. Free logical palette etc.
DeleteObject(Image.Picture.Bitmap.ReleasePalette);
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése