Lazarus

Programming => Operating Systems => Linux => Topic started by: Grahame Grieve on November 01, 2021, 03:07:08 am

Title: Problems rendering bitmaps in Linux
Post by: Grahame Grieve on November 01, 2021, 03:07:08 am
I'm porting PDFium to Lazarus (again). There's an older port, but it's windows only, and doesn't do some things I wanted. And it's not in Git. So: https://github.com/grahamegrieve/PdfiumLib

It compiles for Windows, Linux and OSX, and the example works fine on Windows. But on linux, I get an exception rendering the PDF. The source of the exception is in gtk2widgetset.inc, line 4285:

  if SrcDevContext.Drawable = nil then RaiseSrcDrawableNil;

SrcDevContext is indeed nil. I don't know why - should it be? or what should I do to make it not nil? The code that sets up the error is in PDFiumCtrl (line 750):

    PageDC := CreateCompatibleDC(DC);
    OldPageBmp := SelectObject(PageDC, FPageBitmap);
    try
      if FRenderedPageIndex <> PageIndex then
      begin
        FRenderedPageIndex := PageIndex;
        Draw(PageDC, 0, 0, Page);
      end;
      BitBlt(DC, FDrawX, FDrawY, FDrawWidth, FDrawHeight, PageDC, 0, 0, SRCCOPY);     

There's a whole set of things going on here that I'm not familar with around DCs and bitmaps, and it all works on windows, but not linux. is it me doing something wrong?

Lazarus Version: 2.3.0, trunk 25th Oct, revision = main-2_3-520-gcff7d7fdb8. To reproduce, https://github.com/bblanchon/pdfium-binaries tag c854f3e80a81e0999b68596d40c6b1f99a34ee1a , compile the example and open any PDF (I think)
Title: Re: Problems rendering bitmaps in Linux
Post by: VTwin on January 17, 2022, 11:17:17 pm
May be a bug. Perhaps you might consider a more cross-platform solution? See felipemdc's comments:

https://forum.lazarus.freepascal.org/index.php?topic=3383.0

I have had great success using BGRABitmap on several flavors of Windows, maxOS, and Linux.
TinyPortal © 2005-2018