[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
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

Code links



last edited (November 18, 2006) by bilderbikkel, Number of views: 2098, Current Rev: 5 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.