Recent

Author Topic: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2  (Read 20794 times)

Osvaldo Arruda

  • New Member
  • *
  • Posts: 27
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #15 on: November 05, 2012, 02:03:45 pm »
1. Error:

  P := Point(x,y);
  DpToLP(ACanvas.Handle, @P, 1);

TO:
  P := Point(x,y);
  DpToLP(ACanvas.Handle, P, 1);


2. Erorr:

  P := Point(x,y);
  DpToLP(ACanvas.Handle, @P, 1);

TO:

  P := Point(x,y);
  DpToLP(CanvasSource.Handle, P, 1);

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #16 on: November 05, 2012, 04:00:06 pm »
@Dibo:

Ok I wait for more information.

Maybe we need to take the opposite number instead.

About svn, I'm still using old svn repository. I had problem with the new one. I'll try to switch to the new repository when I have some time to do so.

@Osvaldo:

I suppose you're right if it's simply a "var" type. But it seems to work anyway. Is there a syntax extension that allows to use @ here? It's rather C syntax using &.
« Last Edit: November 05, 2012, 04:08:39 pm by circular »
Conscience is the debugger of the mind

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #17 on: November 05, 2012, 04:26:54 pm »
About svn, I'm still using old svn repository. I had problem with the new one. I'll try to switch to the new repository when I have some time to do so.
What is old svn link? Can't find it on wiki

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #18 on: November 05, 2012, 09:42:59 pm »
Ok i've updated the new svn.
Conscience is the debugger of the mind

Thomas Munk

  • New member
  • *
  • Posts: 7
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #19 on: October 25, 2013, 10:40:37 pm »
I'm not sure - what's the status of this problem?


I doing a new project in Lazarus 1.0.12 (both Windows and Linux/GTK2). I have checked out new newest BGRABitmap from svn.


I'm using TBGRABitmap.Draw on a TGraphicControl descendant's canvas - and it's not working: in a simple for x,y loop painting the same bitmap in a grid, they position like random (on Linux). In Windows it paints fine.


Then I changed the code in TBGRAGtkBitmap.DrawTransparent as described in Reply #10 - and now it works on Linux.
P: TPoint and DPtoLP can then be removed.


Is current svn supposed to be working or does it need this fix?


btw, Thanx for a fine lib

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #20 on: January 19, 2014, 11:25:24 pm »
I'm using Lazarus 1.0.14 with BGRABitmap 7.2, and find what seems to be a related bug, so thought I would mention it here.

When drawing a bitmap to a PaintBox canvas, OS X and Windows use local coordinates, but Linux uses global. My code looks like this:

Code: [Select]
    fBuffer := BmpResize(fBitmap, w, h, fFineResample);
    {$IFDEF LINUX} // bug!!!
    fBuffer.Draw(fView.Canvas, x + fView.Left, y + fView.Top, fOpaque);
    {$ELSE}
    fBuffer.Draw(fView.Canvas, x, y, fOpaque);
    {$ENDIF}

where fBuffer and fBitmap are TBGRABitmaps and fView is a PaintBox. This took me many hours to track down, maybe helpful to someone.

Cheers,
Frederick
« Last Edit: January 19, 2014, 11:28:01 pm by Frederick »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #21 on: March 27, 2014, 04:33:08 am »
Frederick, does the fix mentionned by Thomas Munk solve your problem too?

It is to use the following code in BGRAGtkBitmap.pas, in the procedure TBGRAGtkBitmap.DrawTransparent(ACanvas: TCanvas; Rect: TRect) :
Quote
  gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).ClipRect.X+Rect.Left,
    TGtkDeviceContext(ACanvas.Handle).ClipRect.y+Rect.Top,
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);   
Instead of
Quote
  P := Rect.TopLeft;
  DpToLP(ACanvas.Handle, P, 1);
  gdk_pixbuf_render_to_drawable(FPixBuf,
    TGtkDeviceContext(ACanvas.Handle).Drawable,
    TGtkDeviceContext(ACanvas.Handle).GC,
    0,0,
    TGtkDeviceContext(ACanvas.Handle).Offset.X + abs(P.X),
    TGtkDeviceContext(ACanvas.Handle).Offset.Y + abs(P.Y),
    Width,Height,
    GDK_RGB_DITHER_NORMAL,0,0);   

I don't have Linux and I am getting contradictory feedbacks, so I need more confirmations to know what code to put there!
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #22 on: March 27, 2014, 06:37:14 pm »
Basically it means that you need to get linux, at least in a virtual machine :)

I'll need the bgrabitmap linux working for some project, so i'll need my virtual machine too.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #23 on: March 30, 2014, 06:39:37 pm »
Yes. I found Lubuntu that seems light enough for me.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: BGRABitmap - drawing coordinates changed since Lazarus 1.0.2
« Reply #24 on: March 31, 2014, 12:33:55 am »
Ok I guess I understand.

We need to use LPtoDP function (logical to device) instead of DPtoLP. This explains the sign issue we had before.

I am not surewhy then Dibo had a problem and proposed to use ClipRect. Maybe it is because on Linux, the packages are not recompiled automatically when the files in it are modified.

I have fixed it on SVN, at least it was working on my virtual machine with Lubuntu with a PaintBox.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018