<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Comments for Printing a TImage</title>
<link rel="alternate" type="text/plain" href="http://edn.embarcadero.com/article/22018" title="Printing a TImage" />
<link rel="self" type="application/atom+xml" href="http://edn.embarcadero.com/article/22018/feed" title="Comments for Printing a TImage" />
<id>http://edn.embarcadero.com/article/22018</id>
<updated>2013-06-19T16:37:34-07:00</updated>
<entry>
<title>re: Printing a TImage</title>
<author>
<name>murat maman</name>
<uri>http://threads.embarcadero.com/threads/threads.exe/userall?commentid=34876</uri>
</author>
<id>http://threads.embarcadero.com/threads/threads.exe/view?commentid=34876</id>
<updated>2003-06-30T23:57:42-07:00</updated>
<published>2003-06-30T23:57:42-07:00</published>
<summary>re: Printing a TImage</summary>
<content>I solve other problem. Now working good.void __fastcall TfUserReport::Button1Click(TObject *Sender){/*-----------------------------------------------------------------------This function is the OnClick event of a TButton that is on a TForm.  On the TForm is also a TImage named image.------------------------------------------------------------------------*/    TPrinter *p = Printer();    // create a memory dc for the image    HDC h_dc = image-&gt;Picture-&gt;Bitmap-&gt;Canvas-&gt;Handle;    int bmp_w = image-&gt;Picture-&gt;Bitmap-&gt;Width,    bmp_h = image-&gt;Picture-&gt;Bitmap-&gt;Height;    HDC h_mem_dc = ::CreateCompatibleDC (h_dc);    HBITMAP h_mem_bmp = ::CreateCompatibleBitmap (h_dc, bmp_w, bmp_h);    HBITMAP h_old_bmp = ::SelectObject (h_mem_dc, h_mem_bmp);    // fix up bad video drivers    bool is_pal_dev = false;    LOGPALETTE *pal;    HPALETTE h_pal, h_old_pal;    if (::GetDeviceCaps (image-&gt;Canvas-&gt;Handle, RASTERCAPS) &amp; RC_PALETTE)    {        pal = static_cast&lt;LOGPALETTE *&gt;( malloc (sizeof (LOGPALETTE) + (sizeof (PALETTEENTRY) * 256)));        memset (pal, 0, sizeof (LOGPALETTE) + (sizeof (PALETTEENTRY) * 256));        pal-&gt;palVersion = 0x300;        pal-&gt;palNumEntries = ::GetSystemPaletteEntries(image-&gt;Canvas-&gt;Handle, 0, 256, pal-&gt;palPalEntry);        if (pal-&gt;palNumEntries != 0)        {            h_pal = ::CreatePalette (pal);            h_old_pal = ::SelectPalette (h_mem_dc, h_pal, false);            is_pal_dev = true;        }        else        {            free (pal);        }    }    // copy the image on to the memory dc    ::BitBlt (h_mem_dc, 0, 0, bmp_w, bmp_h, h_dc, 0, 0, SRCCOPY);    if (is_pal_dev)    {        ::SelectPalette (h_mem_dc, h_old_pal, false);        ::DeleteObject (h_pal);    }    // delete the mem dc    ::SelectObject (h_mem_dc, h_old_bmp);    ::DeleteDC (h_mem_dc);    // get memory for a BITMAPIFO Structure    HANDLE h_bmp_info = ::GlobalAlloc (GHND, sizeof (BITMA</content>
</entry>
<entry>
<title>re: Printing a TImage</title>
<author>
<name>murat maman</name>
<uri>http://threads.embarcadero.com/threads/threads.exe/userall?commentid=34875</uri>
</author>
<id>http://threads.embarcadero.com/threads/threads.exe/view?commentid=34875</id>
<updated>2003-06-30T23:54:47-07:00</updated>
<published>2003-06-30T23:54:47-07:00</published>
<summary>re: Printing a TImage</summary>
<content>I solve it pal = static_cast&lt;LOGPALETTE *&gt;(malloc (sizeof (LOGPALETTE) + (sizeof (PALETTEENTRY) * 256)));</content>
</entry>
<entry>
<title>re: Printing a TImage</title>
<author>
<name>vozova hradba</name>
<uri>http://threads.embarcadero.com/threads/threads.exe/userall?commentid=34192</uri>
</author>
<id>http://threads.embarcadero.com/threads/threads.exe/view?commentid=34192</id>
<updated>2003-02-27T13:30:08-08:00</updated>
<published>2003-02-27T13:30:08-08:00</published>
<summary>re: Printing a TImage</summary>
<content>I think that the solution is something like this:...pal = static_cast&lt;LOGPALETTE *&gt;(malloc (sizeof (LOGPALETTE) + (sizeof (PALETTEENTRY) * 256)));...(or &lt;BITMAPINFO*&gt; for the second error)Regards,C.W.</content>
</entry>
<entry>
<title>Printing a TImage</title>
<author>
<name>Zacarias Occidente</name>
<uri>http://threads.embarcadero.com/threads/threads.exe/userall?commentid=33353</uri>
</author>
<id>http://threads.embarcadero.com/threads/threads.exe/view?commentid=33353</id>
<updated>2002-10-20T11:34:05-07:00</updated>
<published>2002-10-20T11:34:05-07:00</published>
<summary>Printing a TImage</summary>
<content>I tried to used this method and failed me in some printers. I use Builder 5. &#191;more solutions?</content>
</entry>
<entry>
<title>Printing a TImage</title>
<author>
<name>Roel Slangen</name>
<uri>http://threads.embarcadero.com/threads/threads.exe/userall?commentid=29060</uri>
</author>
<id>http://threads.embarcadero.com/threads/threads.exe/view?commentid=29060</id>
<updated>2001-05-31T03:07:45-07:00</updated>
<published>2001-05-31T03:07:45-07:00</published>
<summary>Printing a TImage</summary>
<content>How can I solve this ?I get an error on this line:pal = static_cast(malloc (sizeof (LOGPALETTE) + (sizeof (PALETTEENTRY) * 256)));Error code :E2274 &lt; Expected</content>
</entry>
</feed>
