[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppVclScanLine
The function ScanLine returns a void*, therefore it needs to be cast to an unsigned char pointer. Note that red, green and blue are reversed in the obtained pointer. Also note that the image can be drawn on the screen entirely after the graphical operation. I've made the TImage invisible in the first line. This avoids flicker.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppVclScanLine
(C++ VCL) ScanLine
TBitmap method returning a void* to the indexed row of a bitmap, which can be used for quick low-level graphics.Example using TImage
Image1->Visible = false;
const int maxx = Image1->Width;
const int maxy = Image1->Height;
for (int y = 0; y != maxy; ++y)
{
unsigned char * myLine =
static_cast<unsigned char*>(Image1->Picture->Bitmap->ScanLine[y]);
for (int x = 0; x != maxx; ++x)
{
myLine[x*3+2] = x ; //Red
myLine[x*3+1] = y ; //Green
myLine[x*3+0] = x+y; //Blue
}
}
//Actually draw it on Form1
Form1->Canvas->Draw(0,0,Image1->Picture->Graphic);
The function ScanLine returns a void*, therefore it needs to be cast to an unsigned char pointer. Note that red, green and blue are reversed in the obtained pointer. Also note that the image can be drawn on the screen entirely after the graphical operation. I've made the TImage invisible in the first line. This avoids flicker.
ScanLine links
- C++ CLX ScanLine
- Pascal VCL ScanLine
- Pascal CLX ScanLine
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
