diff --git a/examples/scanline/bitmapscanline1.lpi b/examples/scanline/bitmapscanline1.lpi index a166f9d0b7..dca47cc2a9 100644 --- a/examples/scanline/bitmapscanline1.lpi +++ b/examples/scanline/bitmapscanline1.lpi @@ -1,26 +1,26 @@ - + - + + + + + - - - </General> - <VersionInfo> - <ProjectVersion Value=""/> - </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="default" Default="True"/> + </BuildModes> <PublishOptions> <Version Value="2"/> - <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> - <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> </PublishOptions> <RunParams> - <local> - <FormatVersion Value="1"/> - </local> + <FormatVersion Value="2"/> + <Modes Count="1"> + <Mode0 Name="default"/> + </Modes> </RunParams> <RequiredPackages Count="1"> <Item1> @@ -35,30 +35,30 @@ </Unit0> <Unit1> <Filename Value="unit1.pas"/> - <ComponentName Value="Form1"/> <IsPartOfProject Value="True"/> - <ResourceFilename Value="unit1.lrs"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> <UnitName Value="Unit1"/> </Unit1> </Units> </ProjectOptions> <CompilerOptions> - <Version Value="5"/> - <SearchPaths> - - </SearchPaths> - <CodeGeneration> - <Generate Value="Faster"/> - </CodeGeneration> + <Version Value="11"/> + <Parsing> + <SyntaxOptions> + <UseAnsiStrings Value="False"/> + </SyntaxOptions> + </Parsing> <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> <Options> <Win32> <GraphicApplication Value="True"/> </Win32> </Options> </Linking> - <Other> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> </CONFIG> diff --git a/examples/scanline/unit1.lfm b/examples/scanline/unit1.lfm index 5721b87b41..95c10490f7 100644 --- a/examples/scanline/unit1.lfm +++ b/examples/scanline/unit1.lfm @@ -8,14 +8,15 @@ object Form1: TForm1 Caption = 'Form1' ClientHeight = 144 ClientWidth = 623 + LCLVersion = '3.99.0.0' OnCreate = FormCreate OnDestroy = FormDestroy OnPaint = FormPaint object Label1: TLabel Left = 156 - Height = 43 + Height = 15 Top = 42 - Width = 348 + Width = 380 Caption = 'You should see a small rectangle filled with black and a diagonal red line' ParentColor = False WordWrap = True diff --git a/examples/scanline/unit1.pas b/examples/scanline/unit1.pas index 720fd2bfd0..c7a257e306 100644 --- a/examples/scanline/unit1.pas +++ b/examples/scanline/unit1.pas @@ -55,7 +55,7 @@ type private public MyBitmap: TBitmap; - procedure PaintToRGB32bitScanLine(Row, ImgWidth: integer; LineStart: Pointer); + procedure PaintToRGBScanLine(Row, ImgWidth: integer; LineStart: Pointer); end; var @@ -76,22 +76,22 @@ var begin MyBitmap:=TBitmap.Create; - // create an image with a format similar to Delphi's pf32bit - // keep in mind that you access it in bytes, not words or dwords + // Create an image with a format similar to Delphi's pf24bit. + // Keep in mind that you access it in bytes, not words nor dwords // For example PowerPC uses another byte order (endian big) ScanLineImage:=TLazIntfImage.Create(0,0); - ImgFormatDescription.Init_BPP32_B8G8R8_BIO_TTB(30,20); + ImgFormatDescription.Init_BPP24_B8G8R8_BIO_TTB(30,20); ScanLineImage.DataDescription:=ImgFormatDescription; // call the pf24bit specific drawing function for y:=0 to ScanLineImage.Height-1 do - PaintToRGB32bitScanLine(y,ScanLineImage.Width, - ScanLineImage.GetDataLineStart(y)); + PaintToRGBScanLine(y, ScanLineImage.Width, ScanLineImage.GetDataLineStart(y)); // create IntfImage with the format of the current LCL interface MyBitmap.Width:=ScanLineImage.Width; MyBitmap.Height:=ScanLineImage.Height; IntfImage:=MyBitmap.CreateIntfImage; + // convert the content from the very specific to the current format IntfImage.CopyPixels(ScanLineImage); MyBitmap.LoadFromIntfImage(IntfImage); @@ -110,19 +110,21 @@ begin Canvas.Draw(10,10,MyBitmap); end; -procedure TForm1.PaintToRGB32bitScanLine(Row, ImgWidth: integer; +procedure TForm1.PaintToRGBScanLine(Row, ImgWidth: integer; LineStart: Pointer); -// LineStart is pointer to the start of a scanline with the following format: -// 4 bytes per pixel. First byte is blue, second green, third is red. +// LineStart is a pointer to the start of a scanline with the following format: +// - 3 bytes per pixel. +// - First byte is blue, second green, third is red. // Black is 0,0,0, white is 255,255,255 var i: Integer; begin - // fill line with gray - for i:=0 to (ImgWidth*4)-1 do - PByte(LineStart)[i]:=0; // set red, green and blue to 0 (i.e. black) - // set one pixel to red (this creates a red line) - PByte(LineStart)[(Row mod ImgWidth)*4+2]:=255; + // Fill line with background color + for i := 0 to ImgWidth * 3 - 1 do + PByte(LineStart)[i] := 0; // Set red, green and blue to 0 (i.e. black) + + // Set one pixel to red (this creates a red line) + PByte(LineStart)[(Row mod ImgWidth) * 3 + 2] := 255; // We add 2 to address the "red" byte end; end.