From: "Paul Nicholls" Subject: Re: Accessing a TBitmap with BASM Date: 06 Aug 1999 00:00:00 GMT Message-ID: <7od8oc$s3f12@forums.borland.com> References: <7oagqi$pcp15@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Reply-To: "Paul Nicholls" Newsgroups: borland.public.delphi.basm Thanks all for your help. I did it in Pascal and then managed to access a bitmap with assembly. If anyone is interested in the code (probably not the most efficient though) here it is... unit frmBitmap; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) procedure DrawFrame; procedure FormResize(Sender: TObject); private { Private declarations } Buffer : TBitmap; public { Public declarations } end; var Form1 : TForm1; implementation {$R *.DFM} procedure TForm1.DrawFrame; var x,y : integer; b_w,b_h : Integer; w,h : Integer; P : PWordArray; Delta : LongInt; r,g,b : LongInt; begin Buffer := TBitmap.create; try Buffer.PixelFormat := pf16bit; Buffer.Width := 320; Buffer.Height := 200; b_w := (Buffer.Width shr 1)-1; b_h := Buffer.Height-1; w := ClientWidth-1; h := ClientHeight-1; P := Buffer.ScanLine[0]; // workout the next scanline offset and direction Delta := LongInt(Buffer.ScanLine[1])-LongInt(Buffer.ScanLine[0]); r := 31; g := 0; b := 0; Asm mov eax,LongInt(P) xor edx,edx xor ecx,ecx @YLoop: push ecx @XLoop: shl ecx,1 push edx xor edx,edx and r,31 and g,63 and b,31 or edx,r shl edx,5 or edx,g shl edx,6 or edx,b shl edx,16 or edx,r shl edx,5 or edx,g shl edx,6 or edx,b // fill in double word in bitmap mov dword ptr[eax+ecx],edx pop edx shr ecx,1 inc ecx cmp ecx,b_w jbe @XLoop add eax,Delta inc edx cmp edx,b_h pop ecx jbe @YLoop End; StretchBlt(Canvas.Handle,0,0,w,h,Buffer.Canvas.Handle,0,0,b_w,b_h,SRCCOPY); finally Buffer.free; end; end; procedure TForm1.FormResize(Sender: TObject); begin DrawFrame; end; end. -- Paul Nicholls. ******************************************************** Live long and optimise -------------------------------- Web Page : www.southcom.com.au/~phantom