69,371
社区成员
发帖
与我相关
我的任务
分享
CMColor *ps_color = &((*alpha_display_info)->ps_color);
/* Apple colour space data structures */
/* RGB Color Value
A color value expressed in the RGB color space is composed of red, green,
and blue component values. Each color component is expressed as a numeric
value within the range of 0 to 65535.
*/
typedef struct
{
guint16 red;
guint16 green;
guint16 blue;
}CMRGBColor;
/* HSV Color Value
A color value expressed in the HSV color space is composed of hue,
saturation, and value component values. Each color component is
expressed as a numeric value within the range of 0 to 65535 inclusive.
The hue value represents a fraction of a circle in which red is
positioned at 0.
*/
typedef struct
{
guint16 hue;
guint16 saturation;
guint16 value;
}CMHSVColor;
/* CMYK Color Value
A color value expressed in the CMYK color space is composed of cyan, magenta,
yellow, and black component values. Each color component is expressed as a
numeric value within the range of 0 to 65535 inclusive, with 0 representing
100% ink (e.g. pure cyan = 0, 65535, 65535, 65535).
*/
typedef struct
{
guint16 cyan;
guint16 magenta;
guint16 yellow;
guint16 black;
}CMCMYKColor;
/* L*a*b* Color Value
The first three values in the color data are, respectively, the colors
lightness, a chrominance, and b chrominance components. The lightness
component is a 16bit value ranging from 0 to 10000. The chrominance
components are each 16bit values ranging from 12800 to 12700. Gray
values are represented by chrominance components of 0 (e.g. pure white
is defined as 10000, 0, 0).
*/
typedef struct
{
guint16 L;
gint16 a;
gint16 b;
} CMLabColor;
/* Gray Color Value
A color value expressed in the Gray color space is composed of a single component,
gray, represented as a numeric value within the range of 0 to 10000.
*/
typedef struct
{
guint16 gray;
} CMGrayColor ;
/* The color union is defined by the CMColor type definition.
*/
typedef union
{
CMRGBColor rgb;
CMHSVColor hsv;
CMLabColor Lab;
CMCMYKColor cmyk;
CMGrayColor gray;
} CMColor;
// CMColor
static int print_cmcolor_to_pro_file(SaveFileDes saveFileDes,
CMColor *ps_color_p, char* openMod) {
if (!ps_color_p) {
return 0;
}
FILE *stream;
char* linefeedp = saveFileDes.linefeedp;
int ret = 1;
stream = fopen(saveFileDes.fileName, openMod);
if (stream == NULL) {
fprintf(stderr, "Cannot open output file.\r\n");
return ret;
}
CMColor ps_color = *ps_color_p;
CMRGBColor rgb = ps_color.rgb;
CMHSVColor hsv = ps_color.hsv;
CMLabColor Lab = ps_color.Lab;
CMCMYKColor cmyk = ps_color.cmyk;
CMGrayColor gray = ps_color.gray;
if (rgb.red) {
//
fprintf(stream, "CMColor.CMRGBColor.red = %d %s", rgb.red, linefeedp);
printf("CMColor.CMRGBColor.red =%d %s", rgb.red, linefeedp);
//
fprintf(stream, "CMColor.CMRGBColor.green = %d %s", rgb.green,
linefeedp);
printf("CMColor.CMRGBColor.green =%d %s", rgb.green, linefeedp);
//
fprintf(stream, "CMColor.CMRGBColor.blue = %d %s", rgb.blue, linefeedp);
printf("CMColor.CMRGBColor.blue =%d %s", rgb.blue, linefeedp);
}
if (hsv.hue) {
//hue
fprintf(stream, "CMColor.CMHSVColor.hue = %d %s", hsv.hue, linefeedp);
printf("CMColor.CMHSVColor.hue =%d %s", hsv.hue, linefeedp);
//saturation
fprintf(stream, "CMColor.CMHSVColor.saturation = %d %s",
hsv.saturation, linefeedp);
printf("CMColor.CMHSVColor.saturation =%d %s", hsv.saturation,
linefeedp);
//value
fprintf(stream, "CMColor.CMHSVColor.value = %d %s", hsv.value,
linefeedp);
printf("CMColor.CMHSVColor.value =%d %s", hsv.value, linefeedp);
}
if (Lab.L) {
//L
fprintf(stream, "CMColor.CMLabColor.L = %d %s", Lab.L, linefeedp);
printf("CMColor.CMLabColor.L =%d %s", Lab.L, linefeedp);
//a
fprintf(stream, "CMColor.CMLabColor.a = %d %s", Lab.a, linefeedp);
printf("CMColor.CMLabColor.a =%d %s", Lab.a, linefeedp);
//b
fprintf(stream, "CMColor.CMLabColor.b = %d %s", Lab.b, linefeedp);
printf("CMColor.CMLabColor.b =%d %s", Lab.b, linefeedp);
}
if (cmyk.cyan) {
//cyan
fprintf(stream, "CMColor.CMCMYKColor.cyan = %d %s", cmyk.cyan,
linefeedp);
printf("CMColor.CMCMYKColor.cyan =%d %s", cmyk.cyan, linefeedp);
//magenta
fprintf(stream, "CMColor.CMCMYKColor.magenta = %d %s", cmyk.magenta,
linefeedp);
printf("CMColor.CMCMYKColor.magenta =%d %s", cmyk.magenta, linefeedp);
//yellow
fprintf(stream, "CMColor.CMCMYKColor.yellow = %d %s", cmyk.yellow,
linefeedp);
printf("CMColor.CMCMYKColor.yellow =%d %s", cmyk.yellow, linefeedp);
//black
fprintf(stream, "CMColor.CMCMYKColor.black = %d %s", cmyk.black,
linefeedp);
printf("CMColor.CMCMYKColor.black =%d %s", cmyk.black, linefeedp);
}
if (gray.gray) {
//L
fprintf(stream, "CMColor.CMGrayColor.gray= %d %s", gray.gray, linefeedp);
printf("CMColor.CMGrayColor.gray =%d %s", gray.gray, linefeedp);
}
ret = fclose(stream);
return ret;
}