Help!Does anyone know it?

解决方案 »

  1.   

    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorConvertOp op = new ColorConvertOp(cs, null);
    BufferedImage grayImage = op.filter(colorImage, null);The way to convert an RGB value to grayscale is to use the following formula: brightness = 0.212671 * R + 0.715160 * G + 0.072169 * B. Assign brightness to the Red, Green, and Blue components of the a new RGB value.以上引自jGuru,希望能对你有所帮助
      

  2.   

    ColorSpace(int type, int numcomponents) 
              Constructs a ColorSpace object given a color space type and the number of components
    构造函数中的第一个参数就可以取ColorSpace中的static int 哦
    也就是说你可以把type换成你说的TYPE_GRAY试试
    那些TYPE_XXX都可以用来做第一个参数哦。从来没用过这个类,刚才翻文档才知道的
      

  3.   

    都是Java 2D的东西:)
    TYPE_XXX 不可以ColorSpace.getInstance(ColorSpace.TYPE_XXX);
    也不可以 ColorSpace(int type, int numcomponents)
    只有CS_XXX才能实例化
    我想这也是他们用不同的前缀的原因。
    用TYPE_XXX 会得到一个java.lang.IllegalArgumentException: Unknown color space
      

  4.   

    to: wangwenyou(王文友)
    那样只能得到8bit grayscale
    thx
      

  5.   

    我真正的问题是:如何构造ColorSpace没实现的色彩空间?
    and,有没有什么Java 2D的书?除了SUN上下载的。
    我知道O'reilly出版过一本,不过找不到。