954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I get an error message

Hello guys,

Can someone help me? I have a scanned document in my system. It's a tiff file.
You will see below the code i have written. The problem is that i get an error message.
The message is like this "A Graphics object cannot be created from an image that has an indexed pixel format."

My code is this:

Private Sub drawnOnPic(ByVal xpos As Integer, ByVal ypos As Integer)

imgDocument.Image = Image.FromFile(pathName & "\" & veranderImageNaam)
Dim g As Graphics = Graphics.FromImage(imgDocument.Image)

Dim Penstyle As New Pen(Color.Red, 5)
g.DrawRectangle(Penstyle, xpos, ypos, 600, 175)

End Sub

ITStrawberry
Newbie Poster
10 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

I have no problem drawing graphics on a .tif image file by using your code.

Have you tried to save the image as a different format before loading it into your PictureBox and drawing the graphics on it?

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

I have already tried saved the same tif file like a jpeg file. But it gives me the same error

ITStrawberry
Newbie Poster
10 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

If possible, attach the scanned image File on your next reply.

I'm scanner-less. :cool:

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: