0

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

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by codeorder
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?

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.