Printing 24 bpp images on VC++ 6.0

Printing 24 bpp images on VC++ 6.0

Post by Luis Vaccar » Sat, 20 Jul 2002 05:27:52


I'm trying to print a 24 bpp bitmap file but printer only
do it in 16 colors. I did following steps:

1)Create a compatible DC from a printer DC (obtained from
a CPrintDialog object)

CDC* Imprimir;

CPrintDialog printDlg(FALSE,PD_ALLPAGES |
PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE |
PD_NOSELECTION|PD_RETURNDC);

if(printDlg.DoModal() == IDOK)
        {
        Imprimir = new CDC;
        Imprimir->Attach(printDlg.GetPrinterDC());

CDC* mem;
HBITMAP bit;
CBitmap l;

bit = (HBITMAP)LoadImage
0,"c:\\luis.bmp",IMAGE_BITMAP,0,0,LR_VGACOLOR |
LR_LOADFROMFILE);

mem = new CDC;
mem->CreateCompatibleDC(Imprimir);

2)Now, I have a bitmap loaded into 'bit' bitmap handler,
so I select that bitmap in mem DC and I copy the bitmap
form the compatible DC to real DC, but all i get is a 16
color image. (of course i did al the all the StartDoc,
StartPage,...., stuff, i only show the bitmap handling to
be more specific).

Thanks

Luis

mem->SelectObject(CBitmap::FromHandle(bit));
Imprimir->StretchBlt(10,10,400,400,mem,0,0,90,90,SRCCOPY);

 
 
 

Printing 24 bpp images on VC++ 6.0

Post by Greg Binkerd [M » Sat, 20 Jul 2002 05:54:40


Hi, Luis.

You should be using a DIB section and StretchDIBits instead.

Look at the following sample for code:

SAMPLE: DibSectn.exe Uses DIBSections in Win32 (Q186221)

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q186221

Thanks,
-Greg
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

--------------------
| Content-Class: urn:content-classes:message


| Subject: Printing 24 bpp images on VC++ 6.0
| Date: Thu, 18 Jul 2002 13:27:52 -0700
| Lines: 43

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcIumZev7BtUxFP3Qnue7tkeMohNzA==
| Newsgroups: microsoft.public.win32.programmer.gdi
| Path: cpmsftngxa08
| Xref: cpmsftngxa08 microsoft.public.win32.programmer.gdi:1664
| NNTP-Posting-Host: TKMSFTNGXA13 10.201.226.41
| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
|
| I'm trying to print a 24 bpp bitmap file but printer only
| do it in 16 colors. I did following steps:
|
| 1)Create a compatible DC from a printer DC (obtained from
| a CPrintDialog object)
|
| CDC* Imprimir;
|
| CPrintDialog printDlg(FALSE,PD_ALLPAGES |
| PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE |
| PD_NOSELECTION|PD_RETURNDC);
|
| if(printDlg.DoModal() == IDOK)
|       {
|       Imprimir = new CDC;
|       Imprimir->Attach(printDlg.GetPrinterDC());
|
| CDC* mem;
| HBITMAP bit;
| CBitmap l;
|
| bit = (HBITMAP)LoadImage
| 0,"c:\\luis.bmp",IMAGE_BITMAP,0,0,LR_VGACOLOR |
| LR_LOADFROMFILE);
|                      
| mem = new CDC;
| mem->CreateCompatibleDC(Imprimir);
|
| 2)Now, I have a bitmap loaded into 'bit' bitmap handler,
| so I select that bitmap in mem DC and I copy the bitmap
| form the compatible DC to real DC, but all i get is a 16
| color image. (of course i did al the all the StartDoc,
| StartPage,...., stuff, i only show the bitmap handling to
| be more specific).
|
| Thanks
|
| Luis
|
| mem->SelectObject(CBitmap::FromHandle(bit));
| Imprimir->StretchBlt(10,10,400,400,mem,0,0,90,90,SRCCOPY);
|  
|
|

 
 
 

Printing 24 bpp images on VC++ 6.0

Post by Luis Vaccar » Sat, 20 Jul 2002 22:14:29


Thanks, I was going to use DIBs, but i didn't wanted, well
I see I have no choice. In a few days you'll receive more
news.

THANK YOU

Quote:>-----Original Message-----
>Hi, Luis.

>You should be using a DIB section and StretchDIBits
instead.

>Look at the following sample for code:

>SAMPLE: DibSectn.exe Uses DIBSections in Win32 (Q186221)

>http://support.microsoft.com/default.aspx?scid=kb;en-
us;Q186221

>Thanks,
>-Greg
>Microsoft Developer Support

>This posting is provided "AS IS" with no warranties, and
confers no rights.
>Visit http://www.microsoft.com/security for current

information on security.

>--------------------
>| Content-Class: urn:content-classes:message


>| Subject: Printing 24 bpp images on VC++ 6.0
>| Date: Thu, 18 Jul 2002 13:27:52 -0700
>| Lines: 43
>| Message-ID: <17e5d01c22e99$97af0960


Quote:>| MIME-Version: 1.0
>| Content-Type: text/plain;
>|   charset="iso-8859-1"
>| Content-Transfer-Encoding: 7bit
>| X-Newsreader: Microsoft CDO for Windows 2000
>| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>| Thread-Index: AcIumZev7BtUxFP3Qnue7tkeMohNzA==
>| Newsgroups: microsoft.public.win32.programmer.gdi
>| Path: cpmsftngxa08
>| Xref: cpmsftngxa08

microsoft.public.win32.programmer.gdi:1664
Quote:>| NNTP-Posting-Host: TKMSFTNGXA13 10.201.226.41
>| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
>|
>| I'm trying to print a 24 bpp bitmap file but printer
only
>| do it in 16 colors. I did following steps:
>|
>| 1)Create a compatible DC from a printer DC (obtained
from
>| a CPrintDialog object)
>|
>| CDC* Imprimir;
>|
>| CPrintDialog printDlg(FALSE,PD_ALLPAGES |
>| PD_USEDEVMODECOPIES | PD_NOPAGENUMS |

PD_HIDEPRINTTOFILE |

- Show quoted text -

Quote:>| PD_NOSELECTION|PD_RETURNDC);
>|
>| if(printDlg.DoModal() == IDOK)
>|   {
>|   Imprimir = new CDC;
>|   Imprimir->Attach(printDlg.GetPrinterDC());
>|
>| CDC* mem;
>| HBITMAP bit;
>| CBitmap l;
>|
>| bit = (HBITMAP)LoadImage
>| 0,"c:\\luis.bmp",IMAGE_BITMAP,0,0,LR_VGACOLOR |
>| LR_LOADFROMFILE);
>|                  
>| mem = new CDC;
>| mem->CreateCompatibleDC(Imprimir);
>|
>| 2)Now, I have a bitmap loaded into 'bit' bitmap
handler,
>| so I select that bitmap in mem DC and I copy the bitmap
>| form the compatible DC to real DC, but all i get is a
16
>| color image. (of course i did al the all the StartDoc,
>| StartPage,...., stuff, i only show the bitmap handling
to
>| be more specific).
>|
>| Thanks
>|
>| Luis
>|
>| mem->SelectObject(CBitmap::FromHandle(bit));
>| Imprimir->StretchBlt

(10,10,400,400,mem,0,0,90,90,SRCCOPY);

- Show quoted text -

Quote:>|  
>|
>|

>.

 
 
 

Printing 24 bpp images on VC++ 6.0

Post by Greg Binkerd [M » Sat, 20 Jul 2002 23:54:20


Thanks for getting back to me, Luis.  Let me know if you have any problems.

Thanks,
-Greg
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

--------------------
| Content-Class: urn:content-classes:message




| Subject: RE: Printing 24 bpp images on VC++ 6.0
| Date: Fri, 19 Jul 2002 06:14:29 -0700
| Lines: 108

| MIME-Version: 1.0
| Content-Type: text/plain;
|       charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcIvJjbBAbdZ3udDQJ2wqJjPafw/wg==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.win32.programmer.gdi
| NNTP-Posting-Host: TKMSFTNGXA11 10.201.226.39
| Path: cpmsftngxa07!tkmsftngp01!cpmsftngxa08
| Xref: cpmsftngxa07 microsoft.public.win32.programmer.gdi:1709
| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
|
| Thanks, I was going to use DIBs, but i didn't wanted, well
| I see I have no choice. In a few days you'll receive more
| news.
|
| THANK YOU

| >-----Original Message-----
| >Hi, Luis.
| >
| >You should be using a DIB section and StretchDIBits
| instead.
| >
| >Look at the following sample for code:
| >
| >SAMPLE: DibSectn.exe Uses DIBSections in Win32 (Q186221)
| >
| >http://support.microsoft.com/default.aspx?scid=kb;en-
| us;Q186221
| >
| >
| >Thanks,
| >-Greg
| >Microsoft Developer Support
| >
| >
| >
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >Visit http://www.microsoft.com/security for current
| information on security.
| >
| >
| >--------------------
| >| Content-Class: urn:content-classes:message



| >| Subject: Printing 24 bpp images on VC++ 6.0
| >| Date: Thu, 18 Jul 2002 13:27:52 -0700
| >| Lines: 43
| >| Message-ID: <17e5d01c22e99$97af0960

| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >|         charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcIumZev7BtUxFP3Qnue7tkeMohNzA==
| >| Newsgroups: microsoft.public.win32.programmer.gdi
| >| Path: cpmsftngxa08
| >| Xref: cpmsftngxa08
| microsoft.public.win32.programmer.gdi:1664
| >| NNTP-Posting-Host: TKMSFTNGXA13 10.201.226.41
| >| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
| >|
| >| I'm trying to print a 24 bpp bitmap file but printer
| only
| >| do it in 16 colors. I did following steps:
| >|
| >| 1)Create a compatible DC from a printer DC (obtained
| from
| >| a CPrintDialog object)
| >|
| >| CDC* Imprimir;
| >|
| >| CPrintDialog printDlg(FALSE,PD_ALLPAGES |
| >| PD_USEDEVMODECOPIES | PD_NOPAGENUMS |
| PD_HIDEPRINTTOFILE |
| >| PD_NOSELECTION|PD_RETURNDC);
| >|
| >| if(printDlg.DoModal() == IDOK)
| >|         {
| >|         Imprimir = new CDC;
| >|         Imprimir->Attach(printDlg.GetPrinterDC());
| >|
| >| CDC* mem;
| >| HBITMAP bit;
| >| CBitmap l;
| >|
| >| bit = (HBITMAP)LoadImage
| >| 0,"c:\\luis.bmp",IMAGE_BITMAP,0,0,LR_VGACOLOR |
| >| LR_LOADFROMFILE);
| >|                        
| >| mem = new CDC;
| >| mem->CreateCompatibleDC(Imprimir);
| >|
| >| 2)Now, I have a bitmap loaded into 'bit' bitmap
| handler,
| >| so I select that bitmap in mem DC and I copy the bitmap
| >| form the compatible DC to real DC, but all i get is a
| 16
| >| color image. (of course i did al the all the StartDoc,
| >| StartPage,...., stuff, i only show the bitmap handling
| to
| >| be more specific).
| >|
| >| Thanks
| >|
| >| Luis
| >|
| >| mem->SelectObject(CBitmap::FromHandle(bit));
| >| Imprimir->StretchBlt
| (10,10,400,400,mem,0,0,90,90,SRCCOPY);
| >|  
| >|
| >|
| >
| >.
| >
|

 
 
 

Printing 24 bpp images on VC++ 6.0

Post by Luis Vaccar » Sun, 21 Jul 2002 05:29:58


I took some stuffs from the example, build my own image
class, and all it worked PERFECT!!!

Thank you Greg!!!

Quote:>-----Original Message-----
>Thanks for getting back to me, Luis.  Let me know if you
have any problems.

>Thanks,
>-Greg
>Microsoft Developer Support

>This posting is provided "AS IS" with no warranties, and
confers no rights.
>Visit http://www.microsoft.com/security for current

information on security.

>--------------------
>| Content-Class: urn:content-classes:message


>| References: <17e5d01c22e99$97af0960



>| Subject: RE: Printing 24 bpp images on VC++ 6.0
>| Date: Fri, 19 Jul 2002 06:14:29 -0700
>| Lines: 108
>| Message-ID: <1b99301c22f26$36c15da0


Quote:>| MIME-Version: 1.0
>| Content-Type: text/plain;
>|   charset="iso-8859-1"
>| Content-Transfer-Encoding: 7bit
>| X-Newsreader: Microsoft CDO for Windows 2000
>| Thread-Index: AcIvJjbBAbdZ3udDQJ2wqJjPafw/wg==
>| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>| Newsgroups: microsoft.public.win32.programmer.gdi
>| NNTP-Posting-Host: TKMSFTNGXA11 10.201.226.39
>| Path: cpmsftngxa07!tkmsftngp01!cpmsftngxa08
>| Xref: cpmsftngxa07

microsoft.public.win32.programmer.gdi:1709
>| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
>|
>| Thanks, I was going to use DIBs, but i didn't wanted,
well
>| I see I have no choice. In a few days you'll receive
more
>| news.
>|
>| THANK YOU
>| >-----Original Message-----
>| >Hi, Luis.
>| >
>| >You should be using a DIB section and StretchDIBits
>| instead.
>| >
>| >Look at the following sample for code:
>| >
>| >SAMPLE: DibSectn.exe Uses DIBSections in Win32
(Q186221)
>| >
>| >http://support.microsoft.com/default.aspx?scid=kb;en-
>| us;Q186221
>| >
>| >
>| >Thanks,
>| >-Greg
>| >Microsoft Developer Support
>| >
>| >
>| >
>| >This posting is provided "AS IS" with no warranties,
and
>| confers no rights.
>| >Visit http://www.microsoft.com/security for current
>| information on security.
>| >
>| >
>| >--------------------
>| >| Content-Class: urn:content-classes:message



>| >| Subject: Printing 24 bpp images on VC++ 6.0
>| >| Date: Thu, 18 Jul 2002 13:27:52 -0700
>| >| Lines: 43
>| >| Message-ID: <17e5d01c22e99$97af0960

>| >| MIME-Version: 1.0
>| >| Content-Type: text/plain;
>| >|     charset="iso-8859-1"
>| >| Content-Transfer-Encoding: 7bit
>| >| X-Newsreader: Microsoft CDO for Windows 2000
>| >| X-MimeOLE: Produced By Microsoft MimeOLE
V5.50.4910.0300
>| >| Thread-Index: AcIumZev7BtUxFP3Qnue7tkeMohNzA==
>| >| Newsgroups: microsoft.public.win32.programmer.gdi
>| >| Path: cpmsftngxa08
>| >| Xref: cpmsftngxa08
>| microsoft.public.win32.programmer.gdi:1664
>| >| NNTP-Posting-Host: TKMSFTNGXA13 10.201.226.41
>| >| X-Tomcat-NG: microsoft.public.win32.programmer.gdi
>| >|
>| >| I'm trying to print a 24 bpp bitmap file but printer
>| only
>| >| do it in 16 colors. I did following steps:
>| >|
>| >| 1)Create a compatible DC from a printer DC (obtained
>| from
>| >| a CPrintDialog object)
>| >|
>| >| CDC* Imprimir;
>| >|
>| >| CPrintDialog printDlg(FALSE,PD_ALLPAGES |
>| >| PD_USEDEVMODECOPIES | PD_NOPAGENUMS |
>| PD_HIDEPRINTTOFILE |
>| >| PD_NOSELECTION|PD_RETURNDC);
>| >|
>| >| if(printDlg.DoModal() == I

{ w O \#nL?#n?Q?  ? DOK)

- Show quoted text -

Quote:>| >|     {
>| >|     Imprimir = new CDC;
>| >|     Imprimir->Attach(printDlg.GetPrinterDC());
>| >|
>| >| CDC* mem;
>| >| HBITMAP bit;
>| >| CBitmap l;
>| >|
>| >| bit = (HBITMAP)LoadImage
>| >| 0,"c:\\luis.bmp",IMAGE_BITMAP,0,0,LR_VGACOLOR |
>| >| LR_LOADFROMFILE);
>| >|                    
>| >|