Beispiel #1
0
        private unsafe int ExtractXYZ(ColorID colorID, CS_XYZ *xyz)
        {
            if (xyz == null)
            {
                return(PSError.kSPBadParameterError);
            }

            Color item = colors[colorID];

            byte c0 = item.Component0;
            byte c1 = item.Component1;
            byte c2 = item.Component2;
            byte c3 = item.Component3;

            if (item.ColorSpace != ColorSpace.XYZSpace)
            {
                int error = ColorServicesConvert.Convert(item.ColorSpace, ColorSpace.XYZSpace, ref c0, ref c1, ref c2, ref c3);
                if (error != PSError.kSPNoError)
                {
                    return(error);
                }
            }

            xyz->x = c0;
            xyz->y = c1;
            xyz->z = c2;

            return(PSError.kSPNoError);
        }
Beispiel #2
0
        private int StuffXYZ(ColorID colorID, CS_XYZ xyz)
        {
            // Clamp the values to the range of [0, 255].
            ushort x = xyz.x;

            if (x > 255)
            {
                x = 255;
            }

            ushort y = xyz.y;

            if (y > 255)
            {
                y = 255;
            }

            ushort z = xyz.z;

            if (z > 255)
            {
                z = 255;
            }

            colors[colorID] = new Color(ColorSpace.XYZSpace, (byte)x, (byte)y, (byte)z, 0);

            return(PSError.kSPNoError);
        }
Beispiel #3
0
        private unsafe int IsBookColor(ColorID colorID, byte *isBookColor)
        {
            if (isBookColor == null)
            {
                return(PSError.kSPBadParameterError);
            }

            *isBookColor = 0;

            return(PSError.kSPNoError);
        }
Beispiel #4
0
        private unsafe int GetNativeSpace(ColorID colorID, ColorSpace *nativeSpace)
        {
            if (nativeSpace == null)
            {
                return(PSError.kSPBadParameterError);
            }

            *nativeSpace = colors[colorID].ColorSpace;

            return(PSError.kSPNoError);
        }
Beispiel #5
0
        private int StuffComponents(ColorID colorID, ColorSpace colorSpace, byte c0, byte c1, byte c2, byte c3)
        {
            if (!IsValidColorSpace(colorSpace))
            {
                return(PSError.kSPBadParameterError);
            }

            colors[colorID] = new Color(colorSpace, c0, c1, c2, c3);

            return(PSError.kSPNoError);
        }
Beispiel #6
0
        private unsafe int ExtractColorName(ColorID colorID, ASZString *colorName)
        {
            if (colorName == null)
            {
                return(PSError.kSPBadParameterError);
            }

            try
            {
                *colorName = zstringSuite.CreateFromString(string.Empty);
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Beispiel #7
0
        private unsafe int Make(ColorID *colorID)
        {
            if (colorID == null)
            {
                return(PSError.kSPBadParameterError);
            }

            try
            {
                colorsIndex++;
                *colorID = new ColorID(colorsIndex);
                colors.Add(*colorID, new Color());
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Beispiel #8
0
        private unsafe int ExtractComponents(ColorID colorID, ColorSpace colorSpace, byte *c0, byte *c1, byte *c2, byte *c3, byte *gamutFlag)
        {
            if (!IsValidColorSpace(colorSpace) || c0 == null || c1 == null || c2 == null || c3 == null)
            {
                return(PSError.kSPBadParameterError);
            }

            Color item = colors[colorID];

            *c0 = item.Component0;
            *c1 = item.Component1;
            *c2 = item.Component2;
            *c3 = item.Component3;

            int error = PSError.kSPNoError;

            if (item.ColorSpace != colorSpace)
            {
                error = ColorServicesConvert.Convert(item.ColorSpace, colorSpace, ref *c0, ref *c1, ref *c2, ref *c3);
            }

            return(error);
        }