Exemplo n.º 1
0
                public override void WriteImageData(IPnmDataWriter dw, Image im)
                {
                    StringBuilder builder = new StringBuilder();

                    for (int i = 0; i < im.Height; i++)
                    {
                        for (int j = 0; j < im.Width; j++)
                        {
                            Color pixel = ((Bitmap)im).GetPixel(j, i);
                            int   num3  = (int)(((pixel.R * 0.3) + (pixel.G * 0.59)) + (pixel.B * 0.11));
                            if (dw is ASCIIDataWriter)
                            {
                                string str = num3.ToString();
                                if ((builder.Length + str.Length) >= 70)
                                {
                                    dw.WriteLine(string.Empty);
                                    builder.Remove(0, builder.Length);
                                }
                                else
                                {
                                    builder.Append(str);
                                }
                            }
                            dw.WriteByte((byte)num3);
                        }
                    }
                    dw.Close();
                }
Exemplo n.º 2
0
                public override void WriteImageData(IPnmDataWriter dw, Image im)
                {
                    StringBuilder builder = new StringBuilder();

                    for (int i = 0; i < im.Height; i++)
                    {
                        for (int j = 0; j < im.Width; j++)
                        {
                            Color pixel = ((Bitmap)im).GetPixel(j, i);
                            if (dw is ASCIIDataWriter)
                            {
                                string str = string.Concat(new object[] { pixel.R, " ", pixel.G, " ", pixel.B, " " });
                                if ((builder.Length + str.Length) >= 70)
                                {
                                    dw.WriteLine(string.Empty);
                                    builder.Remove(0, builder.Length);
                                }
                                else
                                {
                                    builder.Append(str);
                                }
                            }
                            dw.WriteByte(pixel.R);
                            dw.WriteByte(pixel.G);
                            dw.WriteByte(pixel.B);
                        }
                    }
                    dw.Close();
                }
Exemplo n.º 3
0
                public override void WriteImageData(IPnmDataWriter dw, Image im)
                {
                    int num = 0;

                    for (int i = 0; i < im.Height; i++)
                    {
                        for (int j = 0; j < im.Width; j++)
                        {
                            Color pixel = ((Bitmap)im).GetPixel(j, i);
                            int   num4  = (pixel.R + pixel.G) + pixel.B;
                            if (num4 > 0)
                            {
                                dw.WriteByte(1);
                            }
                            else
                            {
                                dw.WriteByte(0);
                            }
                            num++;
                            if ((dw is ASCIIDataWriter) && (num >= 0x22))
                            {
                                num = 0;
                                dw.WriteLine(string.Empty);
                            }
                        }
                    }
                    dw.Close();
                }
Exemplo n.º 4
0
            public static void WritePnm(Stream fs, Image im, PnmEncoding encoding, PnmType ptype)
            {
                IPnmDataWriter iPNMDataWriter = PnmFactory.GetIPNMDataWriter(fs, encoding);

                if (iPNMDataWriter == null)
                {
                    throw new Exception("Currently only Binary and ASCII encoding is supported");
                }
                try
                {
                    iPNMDataWriter.WriteLine(PnmFactory.GetMagicWord(ptype, encoding));
                    iPNMDataWriter.WriteLine(im.Width.ToString() + " " + im.Height.ToString());
                    if (ptype != PnmType.Pbm)
                    {
                        iPNMDataWriter.WriteLine("255");
                    }
                    PnmFactory.GetIPNMWriter(ptype).WriteImageData(iPNMDataWriter, im);
                }
                catch
                {
                    throw;
                }
            }
Exemplo n.º 5
0
 public abstract void WriteImageData(IPnmDataWriter dw, Image im);
Exemplo n.º 6
0
 public override void WriteImageData(IPnmDataWriter dw, Image im)
 {
     StringBuilder builder = new StringBuilder();
     for (int i = 0; i < im.Height; i++)
     {
         for (int j = 0; j < im.Width; j++)
         {
             Color pixel = ((Bitmap)im).GetPixel(j, i);
             if (dw is ASCIIDataWriter)
             {
                 string str = string.Concat(new object[] { pixel.R, " ", pixel.G, " ", pixel.B, " " });
                 if ((builder.Length + str.Length) >= 70)
                 {
                     dw.WriteLine(string.Empty);
                     builder.Remove(0, builder.Length);
                 }
                 else
                 {
                     builder.Append(str);
                 }
             }
             dw.WriteByte(pixel.R);
             dw.WriteByte(pixel.G);
             dw.WriteByte(pixel.B);
         }
     }
     dw.Close();
 }
Exemplo n.º 7
0
 public override void WriteImageData(IPnmDataWriter dw, Image im)
 {
     StringBuilder builder = new StringBuilder();
     for (int i = 0; i < im.Height; i++)
     {
         for (int j = 0; j < im.Width; j++)
         {
             Color pixel = ((Bitmap)im).GetPixel(j, i);
             int num3 = (int)(((pixel.R * 0.3) + (pixel.G * 0.59)) + (pixel.B * 0.11));
             if (dw is ASCIIDataWriter)
             {
                 string str = num3.ToString();
                 if ((builder.Length + str.Length) >= 70)
                 {
                     dw.WriteLine(string.Empty);
                     builder.Remove(0, builder.Length);
                 }
                 else
                 {
                     builder.Append(str);
                 }
             }
             dw.WriteByte((byte)num3);
         }
     }
     dw.Close();
 }
Exemplo n.º 8
0
 public override void WriteImageData(IPnmDataWriter dw, Image im)
 {
     int num = 0;
     for (int i = 0; i < im.Height; i++)
     {
         for (int j = 0; j < im.Width; j++)
         {
             Color pixel = ((Bitmap)im).GetPixel(j, i);
             int num4 = (pixel.R + pixel.G) + pixel.B;
             if (num4 > 0)
             {
                 dw.WriteByte(1);
             }
             else
             {
                 dw.WriteByte(0);
             }
             num++;
             if ((dw is ASCIIDataWriter) && (num >= 0x22))
             {
                 num = 0;
                 dw.WriteLine(string.Empty);
             }
         }
     }
     dw.Close();
 }
Exemplo n.º 9
0
 public abstract void WriteImageData(IPnmDataWriter dw, Image im);