From 72f97252514be44288ce015f2289de5d07a3df83 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Tue, 13 Dec 2005 15:49:17 +0000 Subject: [PATCH] Fixed: crashes when adding the second image --- Packages/D7/X2CLGLD.dof | 2 +- Source/X2CLGraphicList.pas | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Packages/D7/X2CLGLD.dof b/Packages/D7/X2CLGLD.dof index ae587f9..119bf56 100644 --- a/Packages/D7/X2CLGLD.dof +++ b/Packages/D7/X2CLGLD.dof @@ -100,7 +100,7 @@ Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] -RunParams=ip-to-country.csv countries.csv geo.db +RunParams= HostApplication= Launcher= UseLauncher=0 diff --git a/Source/X2CLGraphicList.pas b/Source/X2CLGraphicList.pas index 1a6c927..9215eab 100644 --- a/Source/X2CLGraphicList.pas +++ b/Source/X2CLGraphicList.pas @@ -705,6 +705,19 @@ var pMask: PByteArray; begin + if not FConvert then + begin + AImage := TBitmap.Create(); + AImage.Width := Self.Width; + AImage.Height := Self.Height; + AImage.Canvas.Brush.Color := clWhite; + AImage.Canvas.FillRect(Rect(0, 0, AImage.Width, AImage.Height)); + + AMask := TBitmap.Create(); + AMask.Assign(AImage); + exit; + end; + // Technique used here: draw the image twice, once on the background color, // once on black. Loop through the two images, check if a pixel is the // background color on one image and black on the other; if so then it's @@ -838,6 +851,9 @@ begin if csLoading in ComponentState then exit; + if (AIndex < 0) or (AIndex >= Count) then + exit; + BeginUpdate(); try bmpImage := TBitmap.Create(); @@ -867,7 +883,6 @@ end; procedure TX2GraphicList.RebuildImages(); var - bmpTemp: TBitmap; iIndex: Integer; begin @@ -882,23 +897,8 @@ begin if not Assigned(FContainer) then exit; - if FConvert then - begin - for iIndex := 0 to FContainer.Graphics.Count - 1 do - AddImage(iIndex); - end else - begin - bmpTemp := TBitmap.Create(); - try - bmpTemp.Width := Self.Width; - bmpTemp.Height := Self.Height; - bmpTemp.Canvas.Brush.Color := clWhite; - bmpTemp.Canvas.FillRect(Rect(0, 0, bmpTemp.Width, bmpTemp.Height)); - Add(bmpTemp, bmpTemp); - finally - FreeAndNil(bmpTemp); - end; - end; + for iIndex := 0 to FContainer.Graphics.Count - 1 do + AddImage(iIndex); finally EndUpdate(); end;