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.
Dominique. On Sat, 15 Aug 2009 08:28:53 -0400, <[email protected]> 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 > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
