创建System.Drawing.Imaging.ColorPalette [英] Creating a System.Drawing.Imaging.ColorPalette

查看:79
本文介绍了创建System.Drawing.Imaging.ColorPalette的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建新的System.Drawing.Imaging.ColorPalette? ColorPalette确实没有构造函数的
,而且Entries属性是ReadOnly。我们怎么样?b $ b应该指定除默认值之外的调色板?如果有一个方法

来导入一个Array或Collection of System.Drawing.Color之类的东西,那么

就没有问题,但它的设置方式是正确的现在我非常感觉

就像它没用。有任何想法吗?谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/

解决方案

(从新闻组中删除了mpdotnet.languages.vb)

2008年11月1日星期六19:52:03 -0700,Nathan Sokalski

< nj ******** @ hotmail.comwrote:
< blockquote class =post_quotes>
如何创建新的System.Drawing.Imaging.ColorPalette? ColorPalette

确实

没有构造函数,而Entries属性是ReadOnly。我们怎么样?b $ b应该指定除默认值之外的调色板?如果有一个

方法

来导入一个Array或Collection of System.Drawing.Color之类的东西,那么

就没问题了,但它现在的设置方式我非常感谢

感觉

就像它没用。有任何想法吗?谢谢。



正如文档所说,你特别限制创建一个新的颜色

调色板。也就是说,按照设计,你不能(他们说这是为了确保你不会改变调色板的长度)。但是,您可以修改返回给您的

调色板。数组属性Entries本身是只读的,但是它是实际的调色板条目数组,而数组

本身并不是只读的。因此,您可以通过将它们设置为新颜色来修改调色板的条目




一旦您对调色板进行了所有更改你想要的,把它分回给图像。

。图像使用的调色板将相应更新。


Pete


你需要做什么调色板?不能用

System.Drawing.Imaging.ImageAttributes?


" Nathan Sokalski" < nj ******** @ hotmail.comwrote in message

news:OQ ************** @ TK2MSFTNGP04.phx.gbl .. 。


如何创建新的System.Drawing.Imaging.ColorPalette? ColorPalette

没有构造函数,而Entries属性是ReadOnly。

我们应该指定除默认值之外的调色板?如果有一个

方法来导入一个Array或Collection of System.Drawing.Color或

的东西,那就没问题了,但它的设置方式是正确的现在我

几乎觉得它没用。有任何想法吗?谢谢。

-

Nathan Sokalski
nj * *******@hotmail.com
http:// www.nathansokalski.com/


(从新闻组中删除了mpdotnet.languages.vb)


2008年11月1日星期六23:57:34 -0700,James Hahn< jh *** @ yahoo.comwrote:


你需要什么?用你不能做的调色板来做
System.Drawing.Imaging.ImageAttributes?



我不能代表OP。但两者完全不同。

修改调色板是对图像本身的改变。

ImageAttributes类提供了一种在

_rendering_期间过滤图像的方法。


后者如果你想要不合适以

方式更改图像然后可以保存到文件中,或者如果您没有直接控制渲染(即无法更改代码绘制

图像,以便在

绘图时传递ImageAttributes的实例。此外,没有办法使用ImageAttributes来更改特定索引的颜色

。你可以映射颜色,但如果由于某种原因,

是两个调色板条目,以相同的颜色开始,但应该是

改为两种不同的颜色,ImageAttributes赢了'要做到这一点。


对于某些任务来说,确实可以用它们来完成它们。

但这两个都没有任何方式_equivalent_。


Pete


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
nj********@hotmail.com
http://www.nathansokalski.com/

解决方案

(m.p.dotnet.languages.vb deleted from Newsgroups:)

On Sat, 01 Nov 2008 19:52:03 -0700, Nathan Sokalski
<nj********@hotmail.comwrote:

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.

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


What do you need to do with a palette that you can''t do with
System.Drawing.Imaging.ImageAttributes?

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...

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
nj********@hotmail.com
http://www.nathansokalski.com/


(m.p.dotnet.languages.vb removed from Newsgroup:)

On Sat, 01 Nov 2008 23:57:34 -0700, James Hahn <jh***@yahoo.comwrote:

What do you need to do with a palette that you can''t do with
System.Drawing.Imaging.ImageAttributes?

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


这篇关于创建System.Drawing.Imaging.ColorPalette的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆