コード例 #1
0
        public Image(int width, int height, byte red, byte green, byte blue)
        {
            BaseChunk chunk1 = new ImageHeader(width, height, 8, 2, 0, 0, 0);

            _buffer.AddRange(chunk1.GetData());

            BaseChunk chunk2 = new RGBSpace(0);

            _buffer.AddRange(chunk2.GetData());

            BaseChunk chunk3 = new ImageGamma(1 / 2.2);

            _buffer.AddRange(chunk3.GetData());

            BaseChunk chunk4 = new PhysDimension(3779, 3779, 1);

            _buffer.AddRange(chunk4.GetData());

            BaseChunk chunk5 = new ImageData(width, height, red, green, blue);

            _buffer.AddRange(chunk5.GetData());

            BaseChunk chunk6 = new ImageTrailer();

            _buffer.AddRange(chunk6.GetData());
        }
コード例 #2
0
ファイル: ProjectLS.cs プロジェクト: ivynetca/lapsestudio
        private Bitmap Process8bit(ref Bitmap input, double exposure, RGBSpace cspace)
        {
            int index, factor;

            if (input.PixelFormat == PixelFormat.Format24bppRgb)
            {
                factor = 3;
            }
            else
            {
                factor = 4;
            }

            Bitmap output = (Bitmap)input.Clone();

            System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, input.Width, input.Height);
            BitmapData bmdIn             = input.LockBits(rec, ImageLockMode.ReadOnly, input.PixelFormat);
            BitmapData bmdOut            = output.LockBits(rec, ImageLockMode.ReadOnly, output.PixelFormat);

            unsafe
            {
                for (int y = 0; y < input.Height; y++)
                {
                    byte *row1 = (byte *)bmdIn.Scan0 + (y * bmdIn.Stride);
                    byte *row2 = (byte *)bmdOut.Scan0 + (y * bmdOut.Stride);

                    for (int x = 0; x < input.Width; x++)
                    {
                        index = x * factor;
                        ColorRGB c = new ColorRGB(row1[index + 2], row1[index + 1], row1[index], cspace);
                        BaseProcess(c, exposure);

                        row2[index + 2] = (byte)(c.R * byte.MaxValue);
                        row2[index + 1] = (byte)(c.G * byte.MaxValue);
                        row2[index]     = (byte)(c.B * byte.MaxValue);
                    }
                }
            }
            input.UnlockBits(bmdIn);
            output.UnlockBits(bmdOut);
            return(output);
        }
コード例 #3
0
ファイル: ProjectLS.cs プロジェクト: ivynetca/lapsestudio
 private void Process16bit(string path, string savepath, double exposure, RGBSpace cspace)
 {
     //TODO: make 16bit processing
 }
コード例 #4
0
ファイル: ProjectLS.cs プロジェクト: ivynetca/lapsestudio
        private Bitmap Process8bit(ref Bitmap input, double exposure, RGBSpace cspace)
        {
            int index, factor;
            if (input.PixelFormat == PixelFormat.Format24bppRgb) { factor = 3; }
            else { factor = 4; }

            Bitmap output = (Bitmap)input.Clone();
            System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, input.Width, input.Height);
            BitmapData bmdIn = input.LockBits(rec, ImageLockMode.ReadOnly, input.PixelFormat);
            BitmapData bmdOut = output.LockBits(rec, ImageLockMode.ReadOnly, output.PixelFormat);

            unsafe
            {
                for (int y = 0; y < input.Height; y++)
                {
                    byte* row1 = (byte*)bmdIn.Scan0 + (y * bmdIn.Stride);
                    byte* row2 = (byte*)bmdOut.Scan0 + (y * bmdOut.Stride);

                    for (int x = 0; x < input.Width; x++)
                    {
                        index = x * factor;
                        ColorRGB c = new ColorRGB(row1[index + 2], row1[index + 1], row1[index], cspace);
                        BaseProcess(c, exposure);

                        row2[index + 2] = (byte)(c.R * byte.MaxValue);
                        row2[index + 1] = (byte)(c.G * byte.MaxValue);
                        row2[index] = (byte)(c.B * byte.MaxValue);
                    }
                }

            }
            input.UnlockBits(bmdIn);
            output.UnlockBits(bmdOut);
            return output;
        }
コード例 #5
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
        public static Colour From_HSL(Double3 hsl, RGBSpace space)
        {
            double c = (1 - Mathd.Abs((2.0 * hsl.z) - 1)) * hsl.y;
            double x = c * (1 - Mathd.Abs(((hsl.x * 6.0) % 2) - 1));
            double m = hsl.z - (c / 2.0);
            double h = hsl.x * 6;
            int i = Mathd.FloorToInt(h);
            switch (i)
            {
                case 0:
                    return From_RGB(new Double3(c + m, x + m, m), space);

                case 1:
                    return From_RGB(new Double3(x + m, c + m, m), space);

                case 2:
                    return From_RGB(new Double3(m, c + m, x + m), space);

                case 3:
                    return From_RGB(new Double3(m, x + m, c + m), space);

                case 4:
                    return From_RGB(new Double3(x + m, m, c + m), space);

                default:
                    return From_RGB(new Double3(c + m, m, x + m), space);
            }
        }
コード例 #6
0
ファイル: ProjectLS.cs プロジェクト: ivynetca/lapsestudio
 private void Process16bit(string path, string savepath, double exposure, RGBSpace cspace)
 {
     //TODO: make 16bit processing
 }
コード例 #7
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
 public static Double3 To_RGB(Colour col, RGBSpace space)
 {
     RGBDefinition d = rgbSpaces[space];
     Double3 linear = d.fromXYZ * col.val;
     return Mathd.Pow(linear, 1.0 / d.gamma);
 }
コード例 #8
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
        public static Double3 To_HSV(Colour col, RGBSpace space)
        {
            Double3 hsv;
            Double3 rgb = To_RGB(col, space);
            double min = Mathd.Min(rgb.x, rgb.y, rgb.z);
            double max = Mathd.Max(rgb.x, rgb.y, rgb.z);
            double delta = max - min;
            if (max == 0)
            {
                return new Double3(0, 0, 0);
            }
            hsv.y = delta / max;
            hsv.z = max;

            if (rgb.x == max)
                hsv.x = (rgb.y - rgb.z) / delta;
            else if (rgb.y == max)
                hsv.x = 2 + (rgb.z - rgb.x) / delta;
            else
                hsv.x = 4 + (rgb.x - rgb.y) / delta;

            hsv.x *= 60;
            if (hsv.x < 0)
                hsv.x += 360;
            return hsv;
        }
コード例 #9
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
        public static Double3 To_HSL(Colour col, RGBSpace space)
        {
            Double3 hsl;
            Double3 rgb = To_RGB(col, space);
            double min = Mathd.Min(rgb.x, rgb.y, rgb.z);
            double max = Mathd.Max(rgb.x, rgb.y, rgb.z);
            double delta = max - min;
            hsl.z = max - min / 2.0;
            if (delta == 0)
            {
                hsl.x = 0;
                hsl.y = 0;
                return hsl;
            }

            if (rgb.x == max)
                hsl.x = (rgb.y - rgb.z) / delta;
            else if (rgb.y == max)
                hsl.x = 2 + (rgb.z - rgb.x) / delta;
            else
                hsl.x = 4 + (rgb.x - rgb.y) / delta;

            hsl.x *= 60;
            if (hsl.x < 0)
                hsl.x += 360;

            hsl.y = delta / (1 - (Mathd.Abs((2.0 * hsl.z) - 1)));

            return hsl;
        }
コード例 #10
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
 public static bool IsInsideGamut(Colour currentColour, RGBSpace limitingSpace)
 {
     Double3 limitingGamutColour = To_RGB(currentColour, limitingSpace);
     if (limitingGamutColour.MaxVal > 1.0 || limitingGamutColour.MinVal < 0.0 || double.IsNaN(limitingGamutColour.x) || double.IsNaN(limitingGamutColour.y) || double.IsNaN(limitingGamutColour.z))
         return false;
     return true;
 }
コード例 #11
0
ファイル: Colour.cs プロジェクト: Evellex/Eldrinth
 public static Colour From_RGB(Double3 rgb, RGBSpace space)
 {
     RGBDefinition d = rgbSpaces[space];
     Double3 linear = Mathd.Pow(rgb, d.gamma);
     return new Colour(d.toXYZ * linear);
 }