Solved

Getting HBITMAP from TControlCanvas

Posted on 2004-04-28
5
681 Views
Last Modified: 2013-12-03
I am using the Adobe AcroExch OLE interface to extract page images of a PDF document using the PDPAGE.CopyToClipboard function. The clipboard bitmap is then converted to a TIF file using a third party graphics library.

This works fine but is painfully slow at approximately 1 page per 3 seconds.  We have over 1,000,000 pages to convert.

I have another utility, XPDFRasterizer, that is ten times faster that AcroExch but it has a problem with rendering Adobe Master Fonts so I have had to abandon it.

However, I have done some tests using the AcroExch DrawEx function instead of CopyToClipboard and it is also very fast. However, it only works by drawing the PDF page bitmap onto a TForm.Canvas.

The graphics library requires 2 parameters, HBITMAP, HPALETTE or HDC.  My problem is to get a HBITMAP from TForm.Canvas without doing a CopyRect.

Any ideas?

Roger Fedyk

0
Comment
Question by:rfedyk
  • 2
  • 2
5 Comments
 
LVL 3

Assisted Solution

by:MikProg
MikProg earned 250 total points
ID: 10946010
>get a HBITMAP from TForm.Canvas without doing a CopyRect
I don't understand precisely what you need. But bitmap handle in device context of TForm.Canvas can be created

HBITMAP CreateCompatibleBitmap(

    HDC hdc,      // handle to device context
    int nWidth,      // width of bitmap, in pixels  
    int nHeight       // height of bitmap, in pixels  
   );      
=function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; stdcall;

HBITMAP CreateDIBSection(

    HDC hdc,      // handle to device context
    CONST BITMAPINFO *pbmi,      // pointer to structure containing bitmap size, format, and color data
    UINT iUsage,      // color data type indicator: RGB values or palette indices
    VOID *ppvBits,      // pointer to variable to receive a pointer to the bitmap's bit values
    HANDLE hSection,      // optional handle to a file mapping object
    DWORD dwOffset      // offset to the bitmap bit values within the file mapping object
   );      
=function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: UINT;
  var p4: Pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall;

Take look into Graphics.pas
function CopyBitmap(Handle: HBITMAP; OldPalette, NewPalette: HPALETTE;
  var DIB: TDIBSection; Canvas: TCanvas): HBITMAP;
can show you a lot
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10946593

   HBITMAP is Handle to Bitmap ... you can't get it if you don't copy the canvas to Bitmap ...

   Form1.Canvas.Handle - it type HDC - which is handle to DeviceContext ...

   Why you don't want to use CopyRect... ?
0
 
LVL 3

Expert Comment

by:MikProg
ID: 10946803
Ivanov_G, rfedyk> I think here we have lib that works with bitmap handles so API bitmap manipluation functions reqired to create in DC DIB and use DIB handle to place picture to form. Is it?
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 250 total points
ID: 10946855
procedure TForm1.Button1Click(Sender: TObject);
var
  hBitmap : LongWord;
begin
  hBitmap := CreateCompatibleBitmap( Form1.Canvas.Handle, Form1.Width, Form1.Height);
end;
0
 
LVL 33

Expert Comment

by:Slick812
ID: 10954858
hello rfedyk, , can you show the parameters of the
DrawEx   function
??
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unique identifier on a terminal server (rdp) 4 54
How to convert memory stream to PDF file 6 58
update joined tables 2 46
PHP preg_replace code convert to Delphi 14 56
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question