Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

Mac Drawing

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I have a problem getting a portion of a bitmap to reverse on a Mac. I initially thought about using the InvertRect API functions for mac and Win32, but quickly figured out that they were very different indeed. Here's the code I'm currently testing:

procedure TForm1.InvertRect;
var
  r: TRect;
begin
  r.TopLeft := p1;
  r.BottomRight := p2;
  Image1.Canvas.CopyMode := cmDstInvert;
  Image1.Canvas.CopyRect(r, Image1.Canvas, r);
  Image1.Canvas.CopyMode := cmSrcCopy;
end;

p1 and p2 are points set in my mouse events - works like a charm on Windows, does absolutely nothing on the Mac. I'm running 0.9.29. Hints, clues, or workarounds appreciated!

Thanks,
Dave H.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100917/ae337878/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Unknown author

I would do it like this:

1> Work with a bitmap canvas instead of the image canvas 2> Draw your image to the bitmap
3> Convert the bitmap to a TLazIntfImage
4> It should now be trivial to build an image inversion function, you can just create a loop to read and change the pixels 5> Convert the TLazIntfImage back to the bitmap
6> Draw the bitmap in the image canvas

More info here:

http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Working_with_TLazIntfImage

Felipe Monteiro de Carvalho

Reply by email

Daithi Haxton
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 17 lines
I would do it like this: 1> Work with a bitmap canvas instead of the image canvas 2> Draw your image to the bitmap 3> Convert the bitmap to a TLazIntfImage 4> It should now be trivial to build an image inversion function, you can just create a loop to read and change the pixels 5> Convert the TLazIntfImage back to the bitmap 6> Draw the bitmap in the image canvas More info here: http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Working_with_TLazIntfImage -- Felipe Monteiro de Carvalho

Thanks for the tip, Felipe - I will give it a try over the weekend. I'm a bit concerned about the looping, though, as this is a more or less real time display of a waveform ... <sigh> ... lots of pixels...

Be well,
Dave H.

Reply by email