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


C# Image.ConvertIndexed方法代码示例

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


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

示例1: Render

        public void Render(Image image, Drawable drawable, bool preview)
        {
            int size = GetValue<int>("size");

              image.UndoGroupStart();

              var procedure = new Procedure("plug_in_pixelize");
              procedure.Run(image, drawable, size);

              var palette = new MinisteckPalette();
              image.ConvertIndexed(ConvertDitherType.No, ConvertPaletteType.Custom,
               0, false, false, "Ministeck");
              palette.Delete();

              image.ConvertRgb();
              image.UndoGroupEnd();

              // And finally calculate the Ministeck pieces

              using (var painter = new Painter(drawable, size, GetValue<RGB>("color")))
            {
              Shape.Painter = painter;

              int width = drawable.Width / size;
              int height = drawable.Height / size;

              var A = new BoolMatrix(width, height);

              // Fill in shapes
              bool limit = GetValue<bool>("limit");
              var shapes = new ShapeSet();
              shapes.Add((limit) ? 2 : 1, new TwoByTwoShape());
              shapes.Add((limit) ? 8 : 1, new ThreeByOneShape());
              shapes.Add((limit) ? 3 : 1, new TwoByOneShape());
              shapes.Add((limit) ? 2 : 1, new CornerShape());
              shapes.Add((limit) ? 1 : 1, new OneByOneShape());

              Action<int> update = null;
              if (!preview)
            {
              var progress = new Progress(_("Ministeck..."));
              update = y => progress.Update((double) y / height);
            }

              var generator =
            new CoordinateGenerator(new Rectangle(0, 0, width, height), update);
              generator.ForEach(c => {if (!A.Get(c)) shapes.Fits(A, c);});
            }

              drawable.Flush();
              drawable.Update();
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:52,代码来源:Renderer.cs

示例2: Save

        protected override bool Save(Image image, Drawable drawable, 
				 string filename)
        {
            int width = drawable.Width;
              int height = drawable.Height;

              if (!drawable.IsIndexed)
            {
              image.ConvertIndexed(ConvertDitherType.No, ConvertPaletteType.Mono,
                   0, false, false, "");
            }

              var writer = new BinaryWriter(File.Open(filename, FileMode.Create));

              writer.Write((byte) 0);	// Write type
              writer.Write((byte) 0);	// Fixed header

              writer.Write(EncodeInteger(width));
              writer.Write(EncodeInteger(height));

              image.Flatten();

              var rgn = new PixelRgn(drawable, true, false);
              var wbmpImage = new byte[(width + 7) / 8 * height];
              var buf = rgn.GetRect(0, 0, width, height);

              for (int row = 0; row < height; row++)
            {
              for (int col = 0; col < width; col++)
            {
              int offset = col / 8 + row * ((width + 7) / 8);
              if (buf[row * width + col] != 0)
            {
              wbmpImage[offset] |= (byte)(1 << (7 - col % 8));
            }
              else
            {
              wbmpImage[offset] &= (byte)(~(1 << (7 - col % 8)));
            }

              // Check if it's at the end of the byte...
              if (((col + 1) % 8 == 0) || ((col + 1) == width))
            {
              writer.Write(wbmpImage[offset]);
            }
            }
            }

              writer.Close();

              return true;
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:52,代码来源:wbmp.cs


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