|
-
Mar 26th, 2008, 12:51 PM
#1
Thread Starter
Fanatic Member
SetPixel is not supported for images with indexed pixel formats.
Hello: I receive this error when trying to SET the color of a pixel. My images that I'm loading must be in black and white and therefore, I save them as bmp type. I'm looping through my pixels and if i find ones that are black, I determine if they are edge points. If yes, I want to change their pixel color to Red:
For X = 1 To myBmp.Width - 1 'Gets the width, in pixels, of this Image.
i = 0
For Y = 1 To myBmp.Height - 1 'Gets the height, in pixels, of this Image.
Select Case myBmp.GetPixel(X, Y).R 'Gets the color of the pixel
Case 255 'if white, don't do anything.
Case Else
'GET OUTTER EDGE POINTS
'LOOK NORTH
' If (X <> 0 And Y <> 0) Then
If myBmp.GetPixel(X, Y + 1).R = 255 Then
IsOutterPerimeter = True
End If
'LOOK SOUTH
If myBmp.GetPixel(X, Y - 1).R = 255 Then
IsOutterPerimeter = True
End If
'LOOK EAST
If myBmp.GetPixel(X - 1, Y).R = 255 Then
IsOutterPerimeter = True
End If
'LOOK WEST
If myBmp.GetPixel(X + 1, Y).R = 255 Then
IsOutterPerimeter = True
End If
' End If
If IsOutterPerimeter = True Then
'THIS IS THE LINE IT BOMBS ON myBmp.SetPixel(X, Y, System.Drawing.Color.Red)
End if
Has anyone else experienced this?
Any ideas would be appreciated.
Thanks,
Proctor
-
Dec 1st, 2008, 08:09 PM
#2
New Member
Re: SetPixel is not supported for images with indexed pixel formats.
im having the exact same problem just now. did you manage to resolve this or can any one else point me in the right direction?
-
Dec 1st, 2008, 08:45 PM
#3
Re: SetPixel is not supported for images with indexed pixel formats.
What type of image was the Image object created from? You can only use SetPixel on formats that store data on a per pixel basis. Any formats that create each pixel on the fly based on an equation will not be able to set the colour of an individual pixel. For instance, if you draw a black line and your image format stores each pixel then you can change one specific pixel to red. If, however, your image format stores the start point and the end point and generates the rest based on those then there's no way it can change only one of those intermediate pixels.
-
Dec 1st, 2008, 08:48 PM
#4
New Member
Re: SetPixel is not supported for images with indexed pixel formats.
i was working with bmp file and was getting the indexing issue.
ive just saved the file as a jpg and the setPixel method works with this.
-
Dec 1st, 2008, 08:58 PM
#5
Re: SetPixel is not supported for images with indexed pixel formats.
I honestly don't know exactly what an indexed pixel format is but I think that, if you want to maintain your original image format, you can create a new Bitmap object with the same dimensions as your existing Image, create a Graphics object from it and then draw the original Image onto the Bitmap. I believe you should then be able to call SetPixel on the Bitmap.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|