Writing/Saving an Image (The Java™ Tutorials > 2D Graphics > Working with Images) http://download.oracle.com/javase/tutorial/2d/images/saveimage.html FLASHC: [java]getRGB() http://flashc.blogspot.com/2009/05/javagetrgb.html [java]getRGB() getRGB()返回默认 sRGB ColorModel 中表示颜色的 RGB 值。(24-31 位表示 alpha,16-23 位表示红色,8-15 位表示绿色,0-7 位表示蓝色)。 要得到具体R,G,B颜色分量得做个位移 // Color color int rgb = color.getRGB(); int r = (rgb & 16711680) >> 16; int g = (rgb & 65280) >> 8; int b = (rgb & 255); 也可以直接使用Color的getRed(),getGreen(),getBlue()方法得到r,g,b. public int getR(int pixel) { // int alpha = (pixel >> 24) & 0xff; // int red = (pixel >> 16) & 0xff; // int green = (pixel >> 8) & 0xff; // int blue = (pixel) & 0xff; int red = (pixel & 16711680) >> 16; int green = (pixel & 65280) >> 8; int blue = (pixel & 255); return red; }
創作者介紹
創作者 FLASHC 的頭像
peicheng

FLASHC

peicheng 發表在 痞客邦 留言(0) 人氣( 231 )