• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Problem on copy memory containing image bits

Started by mos, 4 June 2009, 11:50:48

Previous topic - Next topic

mos

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

Galfar

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?

mos

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.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk