[Lazarus] Scanline on certain size images seems to be failing : Access Violation...
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat Aug 15 17:33:10 CEST 2009
On Sat, 15 Aug 2009 09:26:59 -0400
<dominique at savagesoftwaresolutions.com> wrote:
> Please ignore,
> I just realised that ScanLineImage.Free was being called before the
> Color_RGBtoColor funcation. Which caused the AV.
> Hence why the code works under Delphi, but was AVing with FreePascal.
Note:
The ScanLine differences have nothing to do with FPC, but with the LCL.
You can use:
{$IFDEF LCL}
Mattias
>
> Dominique.
>
> On Sat, 15 Aug 2009 08:28:53 -0400,
> <dominique at savagesoftwaresolutions.com> wrote:
> > I have the following 2 functions to determine the transparency
> > colour of
> a
> > bitmap...
> >
> > // Returns the transparent color for the bitmap
> > function Bitmap24_TransparentColor(bitmap:TBitmap):TColor;
> > var
> > row : PRGBArray;
> > {$IFDEF FPC}
> > ScanLineImage : TLazIntfImage;
> > {$ENDIF}
> > begin
> > Result := clBlack;
> >
> > if not IsValidBitmap( bitmap, 'Bitmap24_TransparentColor' ) then
> > begin
> > Exit;
> > end;
> >
> > {$IFDEF FPC}
> > ScanLineImage := bitmap.CreateIntfImage;
> > {$ENDIF}
> >
> > {$IFDEF FPC}
> > row := ScanLineImage.GetDataLineStart( bitmap.Height - 1 );
> > {$ELSE}
> > row := bitmap.ScanLine[ bitmap.Height - 1 ];
> > {$ENDIF}
> >
> > {$IFDEF FPC}
> > ScanLineImage.Free;
> > {$ENDIF}
> >
> > Result := Color_RGBtoColor(row[0]);
> > end;
> >
> > // Transforms a RGB color into a standard color
> > function Color_RGBToColor(col : TRGB) : TColor;
> > begin
> > Result := $10000 * col.b + $100 * col.g + col.r; // ACCESS
> > VIOLATION HERE if Image greater than 640x480
> > end;
> >
> > I'm getting an Access violation when passing the row[0] to the
> RGBtoColor.
> > Can anyone see what I might be doing wrong?
> > The only thing I noticed is that it seems to fail when I use images
> greater
> > than 640x480, but I'm willing to concede it may be a bit depth
> > issue. Smaller image sizes seem to work fine.
> >
> > Would I be right in thinking that row[0] is the bottom right corner
> > of
> the
> > image?
> >
> > Thanks,
> >
> > Dominique.
> >
> > --
> > _______________________________________________
> > Lazarus mailing list
> > Lazarus at lists.lazarus.freepascal.org
> > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
More information about the Lazarus
mailing list