I need a pointer to screen_buffer_start for asm lazarus / 39-Graphics ---------------------------------------------------------------------- RWC · 2015-10-10 16:46 OS   : Windows Vista 32bit Home Premium SP2. LAZ  : Lazarus-1.4.2-fpc-2.6.4-win32. CPU  : Intel Core2 Quad CPU Q6600 2.4GHz. RAM : 3GB. PCIE : NVIDIA GeForce GT610. Audo : NVIDIA HD Audio. Dear coders  Many years ago I coded in DOS using microsoft assembler 'masm'.  When Windows XP arrived I learnt some Delphi (on a very basic level) but was  able to mix my old asm code with Pascal.  You can see in the code below that in Delphi I got pointers to buffers e.g 'TextrBufferStart: PByteArray'  by using: 'TextrBufferStart := Image2.Picture.Bitmap.ScanLine[TmpBitmap2.height-1]'  And then I could do:                          asm  //move all 3byte rgb+0 into 4byte array Texture Map              mov esi,TmpBufferStart     //load colour source pointer.              mov edi,TextrBufferStart   //load destination pointer.              etc.... Two questions. 1. Can anyone show me how to get the pointers in Lazarus as it doesn't have    the 'ScanLine' option.  Also, I've read the screen handling examples - flipping etc. and my 3D stuff needs  a fast method without flicker.  In Delphi I used:      InvalidateRect(Form1.Handle,NIL,False); //If draw=True Use API calls to avoid flicker. 2. From your experience with Lazarus, can you show me the best way to do this (for Windows only). Kind regards Roy Campbell. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //***************************************Part of Delphi4  - unit Unit1;interfacetype  TForm1 = class(TForm)    Image1: TImage;    Image2: TImage;    etc...  private    procedure MakeScreen;    Procedure LoadTexture;    procedure MakeMyTable;end. var  Form1: TForm1;  ScreenBuffer,TmpBitmap,TmpBitmap2: Tbitmap;  ScreenBufferStart,TmpBufferStart,TextrBufferStart: PByteArray;  MyBuffer: Array[0..8191] of Byte;  MybufferStart: PByteArray;  etc... implementation procedure TForm1.MakeScreen;begin  ScreenBuffer := TBitmap.create;  try     ScreenBuffer.width  := 512;        //make a screen buffer use     ScreenBuffer.height := 384;        //binary sizes and 32bit pixels      ScreenBuffer.PixelFormat:=pf32bit; //for easier and faster addressing.     Image1.height := ScreenBuffer.height;  //assign to image1 and get screen     Image1.width := ScreenBuffer.width;    //buffer start address     Image1.Picture.Bitmap := ScreenBuffer; //pointer - ScreenBufferStart.     ScreenBufferStart := Image1.Picture.Bitmap.ScanLine[ScreenBuffer.height-1]; //got pointer  finally     ScreenBuffer.free;  end;end; procedure TForm1.LoadTexture;   //make a texture buffer - same size as bmp but 32bitbegin            //pixels for easier addressing - ORGB extra byte is zero.  TmpBitmap := TBitMap.create;  TmpBitmap2 := TBitMap.create;  try     TmpBitmap.LoadFromFile('test.bmp');  //256x256 Windows bmp 24bit rgb.     TmpBufferStart := TmpBitmap.ScanLine[TmpBitmap.height-1];     TmpBitmap2.width  := TmpBitmap.width;     //create 32bit ORGB array for pic     TmpBitmap2.height := TmpBitmap.height;     TmpBitmap2.PixelFormat:=pf32bit;     Image2.width := TmpBitmap2.width;         //assign to image2 and get screen     Image2.height := TmpBitmap2.height;       //buffer start address     Image2.Picture.Bitmap := TmpBitmap2;      //pointer - TextrBufferStart     TextrBufferStart := Image2.Picture.Bitmap.ScanLine[TmpBitmap2.height-1]; //got pointer    asm    //move all 3byte rgb+0 into 4byte array Texture Map     pushad  //save registers - push all double     mov esi,TmpBufferStart    //load index colour source pointer.     mov edi,TextrBufferStart   //load destination pointer.     mov ecx,256*256  //load number of pixels  @Texture_Loop:     mov bx,[esi]       //read 1st Green Blue as word (reading the triples...     add esi,2          //set source to 1st Red     ...with eax will cause a..     mov al,[esi]       //read 1st Red as byte       ..read violation on the..     inc esi            //set source for next read rgb     ..last rgb read)     shl eax,16       //move Red into correct place     mov ax,bx          //move Green Blue into correct place=XRGB     and eax,$00ffffff  //AND out top byte = 0RGB     mov [edi],eax      //write colour to Texture Map     add edi,4          //set dest for next write doubleword     loop @Texture_Loop     popad  //restore registers - pop all double.     end;  finally     TmpBitmap.free;     TmpBitmap2.free;  end;end; //******************************* ---------------------------------------------------------------------- balazsszekely · 2015-10-11 08:11 Hi RWC, Maybe I misunderstood the question but there is a ScanLine method for Bitmaps:    Image1.Picture.Bitmap.ScanLine alternatively you can use the    Image1.Picture.Bitmap.RawImage.Data; If you add windows to the uses clauses, function InvalidateRect is also available. Your delphi code should work just fine regards, GetMem ---------------------------------------------------------------------- RWC · 2015-10-11 17:53 Hi GetMem, When I convert my Delphi code in Lazarus I get an error on ...Scanline but I've just found this On freepascal.org/Fast_direct_pixel_access#TBGRABitmap.ScanLine: TBitmap.ScanLine was a method used frequently on Delphi. But TBitmap.ScanLine is not supported by LCL. There is graphic library BGRABitmap which allows access to scan lines. TBGRABitmap.ScanLine So I could try BGRABitmap but as I only need the start address I'll also look into your second suggestion  TBitmap.RawImage. Many thanks for your reply. best regards RWC. ---------------------------------------------------------------------- RWC · 2015-10-16 01:51 Hello again - I think I've cracked it? maybe. Load 'maptile1.bmp' into a TBitmap Then  converted TBitmap to TLazIntfImage using:     IntfImage1 := TempBitmap.CreateIntfImage; That lets me get a pointer to the TLazIntfImage using:     TmpMapStart := IntfImage1.GetDataLineStart(0); //..like Delphi ScanLine  The code below compiles successfully and runs but I can't display a screen image to test it. I've spent days going through the help files and wiki examples but I can't find any reference to simply loading a bitmap and displying it on the screen? (without using BGRABitmap or TLazIntfImage)  Also, I don't want the displayed image area to stretch or resize but I will need to put some Toolbox panels either side of it. Any help would be welcomed. regards RWC. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  var  Form1: TForm1;  ColMapArray: array[0..4194304] of Byte;  //1024 x 1024 x 32bit  ColMapStart: ^integer;   etc... procedure TForm1.FormCreate(Sender: TObject);begin  ColMapStart := @ColMapArray; // pointer needed until close.  LoadTextures;end;               procedure TForm1.LoadTextures;var   IntfImage1: TLazIntfImage;   TempBitmap: TBitmap;   TmpMapStart: ^Integer;begin   IntfImage1 := TLazIntfImage.Create(0,0);   TempBitmap := TBitmap.Create;   try    TempBitmap.LoadFromFile('maptile1.bmp'); //24bit Windows bitmap uncompressed    IntfImage1 := TempBitmap.CreateIntfImage; //convert TBitmap to TLazIntfImage    TmpMapStart := IntfImage1.GetDataLineStart(0); //..like Delphi ScanLine     //Canvas.Draw(0,0,TempBitmap);      // Gray screen??    //TempBitmap.Draw(Canvas,0,0,True);    //'Draw' not identified??      asm    //move 1024x1024 3byte rgb's into 4byte array ground Map     pushad  //save registers - push all double     mov esi,TmpMapStart    //load index colour source pointer.     mov edi,ColMapStart   //load destination pointer.     mov ecx,1024*1024  //load number of pixels   etc...    end;   finally    IntfImage1.Free;    TempBitmap.Free;  end;end;