English 中文(简体)
为减少巴布亚新几内亚形象中的棕榈树而设定RGB值
原标题:Setting RGB values for reducing palette in PNG Image

页: 1

private BufferedImage setColour(BufferedImage image) {
    IndexColorModel cm = new IndexColorModel(
            3, 
            6,       
            new byte[]{-100, 0, 0, 0, -1, 0},  // r 
            new byte[]{0, -100, 60, 0, -1, 0}, // g
            new byte[]{0, 0, 0, -100, -1, 0}); // b
    BufferedImage img = new BufferedImage(
            image.getWidth(), image.getHeight(),
            BufferedImage.TYPE_BYTE_INDEXED,
            cm);
    Graphics2D g2 = img.createGraphics();
    g2.drawImage(image, 0, 0, null);
    g2.dispose();       
    return img;
}

I understand that each byte array is used for indexing the palette associated with a PNG pixel. What I don t understand, is how to set the values in the byte arrays so that I could only slightly reduce the colour number in the PNG image.

最佳回答

指数化彩色模型基本上列出所有可以用于布图形的颜色,其数值为欧洲法郎。

每一栏

//          red, light green, dark green, blue, white, black
new byte[]{-100,       0,         0,        0,    -1,    0},  // red part
new byte[]{   0,    -100,        60,        0,    -1,    0},  // green part
new byte[]{   0,       0,         0,     -100,    -1,    0}   // blue part

我在评论线上添加了这些内容。

只有这些颜色才会最终用于由此产生的图像,否则所有东西都将以最接近的颜色或两种最接近的颜色大致的格局来估计:

(in - out)
(Image stolen from Rekin s answer.)

如果你不仅想减少6个肤色,而且要减少更多的肤色,你就不得不把更多的肤色列入名单。 你们要么在这里使用预先确定的名单,要么从原始形象的统计数字中加以调整(例如,如果图像主要包括蓝天空,这里包括几个蓝hu,但不是其他色体)。 或者在几处预先界定的棕榈树之间选择,对原始形象的区别最小。

通过使用索引的ColorModel,你也可以使用另外一种科罗摩德尔语。 例如,这将是一个具有4个透明度水平的64英勇空间,平均分配(我认为),每台一台星(每张2比彩色):

new DirectColorModel(8, 0xC0, 0x30, 0x0C, 0x03);

这样做只能使用一线透明度,而使用三条绿灯(人类眼可以更清楚地看到):

new DirectColorModel(8, 0xC0, 0x38, 0x06, 0x01);

我没有与全国人民党一道对他们进行测试。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签