Recent

Author Topic: Problems rendering bitmaps in Linux  (Read 2937 times)

Grahame Grieve

  • Full Member
  • ***
  • Posts: 228
Problems rendering bitmaps in Linux
« 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)

VTwin

  • Hero Member
  • *****
  • Posts: 1096
  • Former Turbo Pascal 3 user
Re: Problems rendering bitmaps in Linux
« Reply #1 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.
“Talk is cheap. Show me the code.” -Linus Torvalds

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

 

TinyPortal © 2005-2018