[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

JohnPaulBR

1/3/2005 12:37:00 PM

Hello,

I´m trying to print an image (captured by scanner), using the
System.Drawing.Image.FromHbitmap(IntPtr Hbitmap). When I run the program, it
works fine, I can capture the image. But when I select to print, an unhandled
exception occurs, as follow:

An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.drawing.dll
Additional information: A generic error occurred in GDI+.

When I use the try-catch block, I receive the following information:

"A generic error occurred in GDI+.
stack trace: System.Drawing.Image.FromHbitmap(IntPtr Hbitmap)"

this is my code:

private void printDocument1_PrintPage(System.Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
Image img2 = Image.FromHbitmap(bmpptr); //the bmpptr var is the image
handle, obtained by the scanning
e.Graphics.DrawImage(img2, 0, 0);
}

Please if somebody could give a tip, I will be very thankful!

--
John Paul
2 Answers

Abhijeet Dev

1/3/2005 7:10:00 PM

0

check if you are deleting bmpptr somewhere else - possibly wrapped in a
bitmap and the bitmap is disposed.

"JohnPaulBR" <JohnPaulBR@discussions.microsoft.com> wrote in message
news:D99807B4-8EF6-4EA6-863B-7FC6A4ED1D1B@microsoft.com...
> Hello,
>
> I´m trying to print an image (captured by scanner), using the
> System.Drawing.Image.FromHbitmap(IntPtr Hbitmap). When I run the program,
> it
> works fine, I can capture the image. But when I select to print, an
> unhandled
> exception occurs, as follow:
>
> An unhandled exception of type
> 'System.Runtime.InteropServices.ExternalException' occurred in
> system.drawing.dll
> Additional information: A generic error occurred in GDI+.
>
> When I use the try-catch block, I receive the following information:
>
> "A generic error occurred in GDI+.
> stack trace: System.Drawing.Image.FromHbitmap(IntPtr Hbitmap)"
>
> this is my code:
>
> private void printDocument1_PrintPage(System.Object sender,
> System.Drawing.Printing.PrintPageEventArgs e)
> {
> Image img2 = Image.FromHbitmap(bmpptr); //the bmpptr var is the image
> handle, obtained by the scanning
> e.Graphics.DrawImage(img2, 0, 0);
> }
>
> Please if somebody could give a tip, I will be very thankful!
>
> --
> John Paul


William Main

1/4/2005 12:14:00 AM

0

Check KB 814675
"Abhijeet Dev" <msnews@abhijeet-dev.net> wrote in message
news:OU2SPfc8EHA.2452@TK2MSFTNGP14.phx.gbl...
> check if you are deleting bmpptr somewhere else - possibly wrapped in a
> bitmap and the bitmap is disposed.
>
> "JohnPaulBR" <JohnPaulBR@discussions.microsoft.com> wrote in message
> news:D99807B4-8EF6-4EA6-863B-7FC6A4ED1D1B@microsoft.com...
>> Hello,
>>
>> I´m trying to print an image (captured by scanner), using the
>> System.Drawing.Image.FromHbitmap(IntPtr Hbitmap). When I run the program,
>> it
>> works fine, I can capture the image. But when I select to print, an
>> unhandled
>> exception occurs, as follow:
>>
>> An unhandled exception of type
>> 'System.Runtime.InteropServices.ExternalException' occurred in
>> system.drawing.dll
>> Additional information: A generic error occurred in GDI+.
>>
>> When I use the try-catch block, I receive the following information:
>>
>> "A generic error occurred in GDI+.
>> stack trace: System.Drawing.Image.FromHbitmap(IntPtr Hbitmap)"
>>
>> this is my code:
>>
>> private void printDocument1_PrintPage(System.Object sender,
>> System.Drawing.Printing.PrintPageEventArgs e)
>> {
>> Image img2 = Image.FromHbitmap(bmpptr); //the bmpptr var is the image
>> handle, obtained by the scanning
>> e.Graphics.DrawImage(img2, 0, 0);
>> }
>>
>> Please if somebody could give a tip, I will be very thankful!
>>
>> --
>> John Paul
>
>