473,506 Members | 13,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can a indexed pixel format be converted to some other format?

Seems that Dot.net can not handle files of Indexed Pixel Format as well as
other types of formats.

Given a file or and Image of type Indexed Pixel Format is there a method to
convert it to some other pixel format?
Thanks
Nov 21 '05 #1
8 12577
..NET can indeed handle indexed pixel files. You can load an image in GIF
format and save it in JPEG format very simply. You just need the correct
ImageFormat setting.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:ue**************@TK2MSFTNGP12.phx.gbl...
Seems that Dot.net can not handle files of Indexed Pixel Format as well as
other types of formats.

Given a file or and Image of type Indexed Pixel Format is there a method
to convert it to some other pixel format?
Thanks

Nov 21 '05 #2
I think my comment was too general by referencing all of DotNet.

I believe I got an exception when I tried to create a Graphics object for
such an Image object.

Thanks


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
.NET can indeed handle indexed pixel files. You can load an image in GIF
format and save it in JPEG format very simply. You just need the correct
ImageFormat setting.

-- snip
Seems that Dot.net can not handle files of Indexed Pixel Format as well
as other types of formats.

Given a file or and Image of type Indexed Pixel Format is there a method
to convert it to some other pixel format?
Thanks


Nov 21 '05 #3
Took me a while to run my program because VS2000. Couldn't run the debugger,
it told me to rerun Setup which I did. That took a while.

Anyway the following is the statement that causes the exception

mPicGraphics = Graphics.FromImage(PictureBoxDocument.Image)

The exception

System.Exception: A Graphics object cannot be created from an image that has
an indexed pixel format.
at System.Drawing.Graphics.FromImage(Image image)
Thanks

" **Developer**" <RE*************@a-znet.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I think my comment was too general by referencing all of DotNet.

I believe I got an exception when I tried to create a Graphics object for
such an Image object.

Thanks


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
.NET can indeed handle indexed pixel files. You can load an image in GIF
format and save it in JPEG format very simply. You just need the correct
ImageFormat setting.

-- snip
Seems that Dot.net can not handle files of Indexed Pixel Format as well
as other types of formats.

Given a file or and Image of type Indexed Pixel Format is there a method
to convert it to some other pixel format?
Thanks



Nov 21 '05 #4
You don't need to get a Graphics object for an image that you want to save
in a different format.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:uq**************@TK2MSFTNGP09.phx.gbl...
Took me a while to run my program because VS2000. Couldn't run the
debugger, it told me to rerun Setup which I did. That took a while.

Anyway the following is the statement that causes the exception

mPicGraphics = Graphics.FromImage(PictureBoxDocument.Image)

The exception

System.Exception: A Graphics object cannot be created from an image that
has an indexed pixel format.
at System.Drawing.Graphics.FromImage(Image image)
Thanks

" **Developer**" <RE*************@a-znet.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I think my comment was too general by referencing all of DotNet.

I believe I got an exception when I tried to create a Graphics object for
such an Image object.

Thanks


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
.NET can indeed handle indexed pixel files. You can load an image in GIF
format and save it in JPEG format very simply. You just need the correct
ImageFormat setting.

-- snip
Seems that Dot.net can not handle files of Indexed Pixel Format as well
as other types of formats.

Given a file or and Image of type Indexed Pixel Format is there a
method to convert it to some other pixel format?
Thanks



Nov 21 '05 #5
I want to do various thing with the image: crop it, copy to clipboard,
rotate it, ...
thanks

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OW**************@TK2MSFTNGP12.phx.gbl...
You don't need to get a Graphics object for an image that you want to save
in a different format.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:uq**************@TK2MSFTNGP09.phx.gbl...
Took me a while to run my program because VS2000. Couldn't run the
debugger, it told me to rerun Setup which I did. That took a while.

Anyway the following is the statement that causes the exception

mPicGraphics = Graphics.FromImage(PictureBoxDocument.Image)

The exception

System.Exception: A Graphics object cannot be created from an image that
has an indexed pixel format.
at System.Drawing.Graphics.FromImage(Image image)
Thanks

" **Developer**" <RE*************@a-znet.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I think my comment was too general by referencing all of DotNet.

I believe I got an exception when I tried to create a Graphics object
for such an Image object.

Thanks


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
.NET can indeed handle indexed pixel files. You can load an image in
GIF format and save it in JPEG format very simply. You just need the
correct ImageFormat setting.

-- snip
> Seems that Dot.net can not handle files of Indexed Pixel Format as
> well as other types of formats.
>
> Given a file or and Image of type Indexed Pixel Format is there a
> method to convert it to some other pixel format?
>
>
> Thanks
>



Nov 21 '05 #6
>> Given a file or and Image of type Indexed Pixel Format is there a
>> method to convert it to some other pixel format?


This is where I am now. Two problems:

1) I don't know what is a good PixelFormat to use.
What is the default?
2)ClonedBitmap has the same (Indexed) PixelFormat as ReadBitmap.
I was hopping it would be converted to Format32bppPArgb (even tho I don't
know that's a good one.)

Thanks for any help

Dim Filestream As Filestream = New Filestream(OpenFileDialog1.FileName,
FileMode.Open)

Dim ReadBitmap As New Bitmap(Filestream)

Dim CloneRect As New RectangleF(0, 0, ReadBitmap.Width, ReadBitmap.Height)

Dim ClonedBitmap = ReadBitmap.Clone(CloneRect,
Imaging.PixelFormat.Format32bppPArgb)
Nov 21 '05 #7
See the GDI+ FAQ

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
>>> Given a file or and Image of type Indexed Pixel Format is there a
>>> method to convert it to some other pixel format?


This is where I am now. Two problems:

1) I don't know what is a good PixelFormat to use.
What is the default?
2)ClonedBitmap has the same (Indexed) PixelFormat as ReadBitmap.
I was hopping it would be converted to Format32bppPArgb (even tho I don't
know that's a good one.)

Thanks for any help

Dim Filestream As Filestream = New Filestream(OpenFileDialog1.FileName,
FileMode.Open)

Dim ReadBitmap As New Bitmap(Filestream)

Dim CloneRect As New RectangleF(0, 0, ReadBitmap.Width, ReadBitmap.Height)

Dim ClonedBitmap = ReadBitmap.Clone(CloneRect,
Imaging.PixelFormat.Format32bppPArgb)

Nov 21 '05 #8
Bob

I just signed on to tell you that I had found the answers on your site.

Thanks

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
See the GDI+ FAQ

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

" **Developer**" <RE*************@a-znet.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
>>>> Given a file or and Image of type Indexed Pixel Format is there a
>>>> method to convert it to some other pixel format?


This is where I am now. Two problems:

1) I don't know what is a good PixelFormat to use.
What is the default?
2)ClonedBitmap has the same (Indexed) PixelFormat as ReadBitmap.
I was hopping it would be converted to Format32bppPArgb (even tho I don't
know that's a good one.)

Thanks for any help

Dim Filestream As Filestream = New Filestream(OpenFileDialog1.FileName,
FileMode.Open)

Dim ReadBitmap As New Bitmap(Filestream)

Dim CloneRect As New RectangleF(0, 0, ReadBitmap.Width,
ReadBitmap.Height)

Dim ClonedBitmap = ReadBitmap.Clone(CloneRect,
Imaging.PixelFormat.Format32bppPArgb)


Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3081
by: unknown | last post by:
some one can give me a portable source codes that color a pixel? (env *nix) -- unknown
0
1514
by: Webgour | last post by:
Hello, I'm tring to create an indexed image on the fly with the following : Bitmap bcodeBitmap = new Bitmap(50,50,PixelFormat.Format32bppArgb); Graphics objGraphics =...
1
7121
by: jty202 | last post by:
I know alot of people have the problem with indexed pixel format. I hope someone can show me the solution to this.I am have problem with graphics with the following code giving the error: "A...
2
4618
by: victor | last post by:
hello, I have several arrays containing (image-) pixel data; I want to display it onto a PictureBox. What is the best Graphics method for it? (MSDN examples talks only about loading it from...
1
1124
by: Jeff Stewart | last post by:
Is there a procedure for determining whether or not an Image uses any of the indexed pixel formats, short of checking against each one? -- Jeff S.
30
9015
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
0
3025
by: Anil Gupte | last post by:
I am using an Image Button from Microsoft's Power Pack. When I use the ..Enabled=True/False I get the following error "SetPixel is not supported for images with indexed pixel formats" I am...
8
4290
by: Joergen Bech | last post by:
Suppose I have Dim bm As New Bitmap(16, 16,Imaging.PixelFormat.Format8bppIndexed) I cannot use Dim g As Graphics = Graphics.FromImage(bmdest) Dim hdc As IntPtr = g.GetHdc() as the...
1
1904
by: Nathan Sokalski | last post by:
I have created declared a Bitmap using the following statement: Dim bmp As New Bitmap(100, 100, PixelFormat.Format8bppIndexed) Because the SetPixel() method is disabled and a Graphics object...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.