469,583 Members | 2,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,583 developers. It's quick & easy.

SetPixel Issue

I would like to change some pixels inside a particular gif file. I
tried using the setpixel and noticed that it is not compatible with
indexed images. Then I converted the file from a gif to a bmp using the
following syntax

imgDiskImage.Save(sNewFile, imgFormat)

Altough the file was converted it failed again when setpixel was called
in the statement

BMImage.SetPixel(Xindex, Yindex, Color.Cyan)

The error message in all the occasions is -
SetPixel is not supported for images with indexed pixel formats.

If I have converted the file to bitmap image why it is still failing?
What I should change? BMImage as declared as
Dim BMImage As Bitmap = CType(Image.FromFile(StrFileNamePath), Bitmap)

I have opened a bmp file created by windows paint and there were no
issues with the setpixel. So I've tried converting the gif file with
Microsoft Office Picture Manager to a bmp but this also failed.

Strange

Thanks
Jansen

Jan 7 '07 #1
1 2181
<ta*********@hotmail.comschrieb:
>I would like to change some pixels inside a particular gif file. I
tried using the setpixel and noticed that it is not compatible with
indexed images. Then I converted the file from a gif to a bmp using the
following syntax

imgDiskImage.Save(sNewFile, imgFormat)

Altough the file was converted it failed again when setpixel was called
in the statement

BMImage.SetPixel(Xindex, Yindex, Color.Cyan)

The error message in all the occasions is -
SetPixel is not supported for images with indexed pixel formats.

If I have converted the file to bitmap image why it is still failing?
The 'Bitmap' class can store both indexed and non-indexed images. GIF files
use a color table and are thus indexed. However, just create a new image of
the same size, use 'Graphics.FromImage(<new bitmap>)' to get a 'Graphics'
object and pass the image object containing the GIF file to its 'DrawImage'
method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Peter | last post: by
reply views Thread by mark | last post: by
2 posts views Thread by Matthew | last post: by
3 posts views Thread by Atmapuri | last post: by
3 posts views Thread by Seabass | last post: by
13 posts views Thread by SAL | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.