?
Solved

Getting HBITMAP from TControlCanvas

Posted on 2004-04-28
5
Medium Priority
?
701 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Assisted Solution

by:MikProg
MikProg earned 750 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 750 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 34

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

800 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