I have the necessity to store in a buffer the bits image so I use this code:
...
FBitmap: TImagingBitmap;
FImage: TSingleImage;
s: LongInt;
gbuff: Pointer;
...
FImage := TSingleImage.Create;
FBitmap := TImagingBitmap.Create;
Image.Picture.Graphic := FBitmap;
...
FImage.LoadFromFile('test.jpg');
Image.Picture.Graphic.Assign(FImage);
s := FImage.Size;
GetMem(gbuff, s);
{$ifdef Linux}
Move(FImage.Bits, gbuff, s);
{$endif}
{$ifdef Win32}
CopyMemory(gbuff, FImage.Bits, s);
{$endif}
The code work well under Windows but under Linux I get an exception on Move instruction.
I use Lazarus 0.9.26 & fpc 2.2.2, WinXP+SP2, Linux Fedora Core 8.
In the attached file there is the complete source code.
Can you help me?
Thanks & goodbye
Move procedure from RTL takes dereferenced pointers as arguments, so you'll need to use it this way:
Move(FImage.Bits^, gbuff^, s);
Btw why do you use CopyMemory instead of Move in Windows?
Yes you have right, now I have seen that in FreePascal the CopyMemory is implemented through a Move! Under Windows I have always used winapi CopyMemory :(
I must read the FreePascal documentation.
Thanks for your suggestion.