473,789 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a System.Drawing. Imaging.ColorPa lette

How do I create a new System.Drawing. Imaging.ColorPa lette? ColorPalette does
not have a constructor, and the Entries property is ReadOnly. How are we
supposed to specify a palette other than the default? If there were a method
to import an Array or Collection of System.Drawing. Color or something, it
would be no problem, but the way it is set up right now I pretty much feel
like it is useless. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 2 '08 #1
10 11447
(m.p.dotnet.lan guages.vb deleted from Newsgroups:)

On Sat, 01 Nov 2008 19:52:03 -0700, Nathan Sokalski
<nj********@hot mail.comwrote:
How do I create a new System.Drawing. Imaging.ColorPa lette? ColorPalette
does
not have a constructor, and the Entries property is ReadOnly. How are we
supposed to specify a palette other than the default? If there were a
method
to import an Array or Collection of System.Drawing. Color or something, it
would be no problem, but the way it is set up right now I pretty much
feel
like it is useless. Any ideas? Thanks.
As the docs say, you are specifically restricted from creating a new color
palette. That is, it's by design that you can't (they say it's to make
sure you don't change the length of the palette). But, you can modify the
palette that's returned to you. The array property Entries is itself
read-only, but it's the actual array of palette entries, and the array
itself isn't read-only. So you can modify the entries of the palette
simply by setting them to a new color.

Once you've made all the changes to the palette you want, assign it back
to the Image. The palette used by the image will be updated accordingly.

Pete
Nov 2 '08 #2
What do you need to do with a palette that you can't do with
System.Drawing. Imaging.ImageAt tributes?

"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:OQ******** ******@TK2MSFTN GP04.phx.gbl...
How do I create a new System.Drawing. Imaging.ColorPa lette? ColorPalette
does not have a constructor, and the Entries property is ReadOnly. How are
we supposed to specify a palette other than the default? If there were a
method to import an Array or Collection of System.Drawing. Color or
something, it would be no problem, but the way it is set up right now I
pretty much feel like it is useless. Any ideas? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 2 '08 #3
(m.p.dotnet.lan guages.vb removed from Newsgroup:)

On Sat, 01 Nov 2008 23:57:34 -0700, James Hahn <jh***@yahoo.co mwrote:
What do you need to do with a palette that you can't do with
System.Drawing. Imaging.ImageAt tributes?
I can't speak for the OP. But the two are completely different things.
Modifying the palette is a change to the image itself. The
ImageAttributes class provides a way to filter the image during
_rendering_.

The latter would be inappropriate if you wanted to change the image in a
way that could then be saved to a file, or if you did not have direct
control over the rendering (i.e. had no way to change the code drawing the
image so that you could pass an instance of ImageAttributes when
drawing). Also, there is no way to use ImageAttributes to change colors
for specific indices. You can map colors, but if for some reason there
are two palette entries that start with the same color but which should be
changed to two different colors, ImageAttributes won't do that.

It's true that for certain tasks, they can be accomplished with either.
But the two are not in any way _equivalent_.

Pete
Nov 2 '08 #4
I'm currious why you dropped the .vb group. The question seems language
independent, and James seems to stick to the vb board, and may not see the
response.

"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
(m.p.dotnet.lan guages.vb removed from Newsgroup:)

Pete
Nov 2 '08 #5
On Sun, 02 Nov 2008 05:41:26 -0700, Family Tree Mike
<Fa************ @thisoldhouse.c omwrote:
I'm currious why you dropped the .vb group. The question seems language
independent, and James seems to stick to the vb board, and may not see
the response.
Knee-jerk on my part. I was considering my reply in context to the
original post, and just assumed that James was posting from the ...drawing
newsgroup. I was using the same logic I used in my reply to the OP, even
though it didn't necessarily apply.

Oh well...that's a risk when people over-cross-post, whether they started
the thread or follow-up to it.

In any case, as for the general reason for deleting the VB.NET
newsgroup...my rule with respect to cross-posts is that when there are two
clearly contradictory newsgroups listed, one has to be deleted.

There is certainly some gray with respect to cross-posting in these .NET
newsgroup, where a newsgroup that's ostensibly language-specific (such as
the C# or VB.NET newsgroup) is used for questions not actually pertaining
to the language per se (such as asking about things in the Imaging or
Forms namespaces). I don't bother trying to argue against that sort of
cross-posting or misdirected posting (in the case where only the language
newsgroup is even used).

But, there is a _very_ clear contradiction between the C# and VB.NET
newsgroups. The only justification for posting non-language questions to
a language newsgroup is the marginal justification that the question is
being asked in the context of using that specific language. It is obvious
(to me) that only one language at a time can apply to questions like this,
and so any other language newsgroups need to be deleted.

I suppose I really ought to just ignore threads like that. I don't feel
comfortable propagating the bad cross-posting myself, and once the
cross-post has been done, you never know where the people other than the
OP are coming from (which is one of the problems with cross-posts,
especially overly broad ones).

Anyway, hope that clears things up, as much as might be possible.

Pete
Nov 2 '08 #6
That makes sense, and thanks for clarifying. I think the VB.Net crowd needs
your wisdom too.

Mike

"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Sun, 02 Nov 2008 05:41:26 -0700, Family Tree Mike
<Fa************ @thisoldhouse.c omwrote:
>I'm currious why you dropped the .vb group. The question seems language
independent, and James seems to stick to the vb board, and may not see
the response.

Knee-jerk on my part. I was considering my reply in context to the
original post, and just assumed that James was posting from the ...drawing
newsgroup. I was using the same logic I used in my reply to the OP, even
though it didn't necessarily apply.

Oh well...that's a risk when people over-cross-post, whether they started
the thread or follow-up to it.

In any case, as for the general reason for deleting the VB.NET
newsgroup...my rule with respect to cross-posts is that when there are two
clearly contradictory newsgroups listed, one has to be deleted.

There is certainly some gray with respect to cross-posting in these .NET
newsgroup, where a newsgroup that's ostensibly language-specific (such as
the C# or VB.NET newsgroup) is used for questions not actually pertaining
to the language per se (such as asking about things in the Imaging or
Forms namespaces). I don't bother trying to argue against that sort of
cross-posting or misdirected posting (in the case where only the language
newsgroup is even used).

But, there is a _very_ clear contradiction between the C# and VB.NET
newsgroups. The only justification for posting non-language questions to
a language newsgroup is the marginal justification that the question is
being asked in the context of using that specific language. It is obvious
(to me) that only one language at a time can apply to questions like this,
and so any other language newsgroups need to be deleted.

I suppose I really ought to just ignore threads like that. I don't feel
comfortable propagating the bad cross-posting myself, and once the
cross-post has been done, you never know where the people other than the
OP are coming from (which is one of the problems with cross-posts,
especially overly broad ones).

Anyway, hope that clears things up, as much as might be possible.

Pete
Nov 2 '08 #7
BTW, microsoft.publi c.dotnet.framew ork.drawing

is a pretty dead board...but at least it's targeted for drawing so you
get a filter.

RL
Nov 3 '08 #8
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
In any case, as for the general reason for deleting the VB.NET
newsgroup...my rule with respect to cross-posts is that when there are two
clearly contradictory newsgroups listed, one has to be deleted.
Honestly, I think you should have removed BOTH language groups. As it
stands, it looks like you had a choice between VB and C# and said "screw
VB." No language was directly indicated in the original post (although words
like ReadOnly were a clue) so ultimately, if I were going to "teach the
poster a lesson," I'd remove everything but .drawing.
Nov 3 '08 #9
On Mon, 03 Nov 2008 14:00:43 -0800, Jeff Johnson <i.***@enough.s pamwrote:
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
>In any case, as for the general reason for deleting the VB.NET
newsgroup... my rule with respect to cross-posts is that when there are
two
clearly contradictory newsgroups listed, one has to be deleted.

Honestly, I think you should have removed BOTH language groups. As it
stands, it looks like you had a choice between VB and C# and said "screw
VB."
That's not what I "said" at all. I simply personally feel that posting
the C# newsgroup and VB.NET newsgroup at the same time is an obvious
contradiction. You're ascribing to me motives I don't have.

As I said before, ideally only questions specific to the _language_ itself
(i.e. how to use some specific feature of the language) are actually
on-topic here. But, by community consensus, questions that are actually
about .NET generally are tolerated as well.

So while I don't disagree that technically the C# newsgroup is off-topic,
I don't feel strongly enough about it to try to instruct others to follow
that constraint, nor even enough to constrain myself in that way (indeed,
many of the answers I post here have nothing to do with C#).

Thus, out of three newsgroups, two are mutually exclusive, and so in
replying one of those two _had_ to be excluded, at least according to my
normal posting habits. Sometimes a habit causes one to do something
that's not entirely correct, but that's not really the point here I think.
No language was directly indicated in the original post (although words
like ReadOnly were a clue) so ultimately, if I were going to "teach the
poster a lesson," I'd remove everything but .drawing.
Well, if I were "going to teach the poster a lesson", perhaps I'd have
done that too. But teaching the OP a lesson wasn't my intent at all. My
removing the VB.NET newsgroup was simply part of my own desire to not be a
part of propagating a faulty posting pattern. Nothing more, nothing less.

YMMV.

Pete
Nov 4 '08 #10

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

Similar topics

7
2321
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving, the other in which I close the FileStream afterwards, although both return the same error. Here are the two versions of the code and the errors they each return (NOTE: I rebooted immediately before running each of these versions so that I knew they...
1
4893
by: Ira | last post by:
I was successful in creating the multipage Tif files in VB.net using the following the following code: Public Sub SaveSeveralOnePageFilesInADir(ByVal DrNm As String, ByVal resultFl As String) Dim pages As Bitmap = Nothing Dim PgCnt As Integer
4
2757
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
9
6563
by: colin | last post by:
Hi, I have all the components of a .bmp file in memory wich i need to write to a .bmp file, (or other convenient image file) ie i have 256 color pallete of RGBquads and array of 8bit pixels, I can create a System.Drawing.Bitmap and it allows me to set the witdh,height,bpp, and even the pixel data, but it doesnt seem to let me set the color palette, the palette property field is read/write but requires a...
2
4557
by: Nathan Sokalski | last post by:
How do I create a new System.Drawing.Imaging.ColorPalette? ColorPalette does not have a constructor, and the Entries property is ReadOnly. How are we supposed to specify a palette other than the default? If there were a method to import an Array or Collection of System.Drawing.Color or something, it would be no problem, but the way it is set up right now I pretty much feel like it is useless. Any ideas? Thanks. -- Nathan Sokalski...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9502
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10178
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9971
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9000
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7521
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5406
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5541
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4080
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 we have to send another system

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.