当前位置: 首页>>代码示例>>Java>>正文


Java ColorSpace.toRGB方法代码示例

本文整理汇总了Java中java.awt.color.ColorSpace.toRGB方法的典型用法代码示例。如果您正苦于以下问题:Java ColorSpace.toRGB方法的具体用法?Java ColorSpace.toRGB怎么用?Java ColorSpace.toRGB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.color.ColorSpace的用法示例。


在下文中一共展示了ColorSpace.toRGB方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public static void main(String[] args) {
   	int sr = 128;
	int sg = 1;
	int sb = 128;
	System.out.format("Input (sRGB) = %d, %d, %d\n", sr, sg, sb);
	System.out.format("XYZref = %10g, %10g, %10g\n", Xref,Yref,Zref);
	
	ColorSpace cs = new LabColorSpace();
	//float[] luv = cs.fromCIEXYZ(new float[] {.1f,.5f,.9f});
	float[] lab = cs.fromRGB(new float[] {sr/255f, sg/255f, sb/255f});

	System.out.format("Lab = %8f, %8f, %8f\n", lab[0],lab[2],lab[2]);
	//float[] xyz = cs.toCIEXYZ(luv);
	float[] srgb = cs.toRGB(lab);
	System.out.format("sRGB = %8f, %8f, %8f\n", 
			Math.rint(255*srgb[0]), Math.rint(255*srgb[1]), Math.rint(255*srgb[2]));
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:18,代码来源:LabColorSpace.java

示例2: runTest

import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DataConversionTests.java

示例3: Color

import java.awt.color.ColorSpace; //导入方法依赖的package包/类
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:Color.java

示例4: Color

import java.awt.color.ColorSpace; //导入方法依赖的package包/类
/**
 * Creates a color in the specified {@code ColorSpace}
 * with the color components specified in the {@code float}
 * array and the specified alpha.  The number of components is
 * determined by the type of the {@code ColorSpace}.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the {@code ColorSpace} to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the {@code ColorSpace}
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         {@code components} array or {@code alpha} is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:Color.java


注:本文中的java.awt.color.ColorSpace.toRGB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。