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


C# Bitmap.InsertColorsToPalette方法代码示例

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


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

示例1: FromTile8bit

        private static Bitmap FromTile8bit(byte* GBAGraphics, int length, Color[] palette, int width, out int emptyGraphicBlocks)
        {
            int heigth = length / width;
            if (heigth % 8 != 0)
                heigth += 8 - (heigth % 8);

            while ((emptyGraphicBlocks = heigth * width - length) < 0)
                heigth += 8;
            emptyGraphicBlocks /= 64;

            Bitmap result = new Bitmap(width, heigth, PixelFormat.Format8bppIndexed);
            result.InsertColorsToPalette(palette);

            BitmapData bData = result.LockBits(new Rectangle(new Point(), result.Size), ImageLockMode.WriteOnly, result.PixelFormat);

            for (int i = 0; i < length; i++)
            {
                byte pixel = GBAGraphics[i];
                int position = bitmapPosition(tiledCoordinate(i, width, 8), width);
                ((byte*)bData.Scan0)[position] = pixel;
            }

            result.UnlockBits(bData);
            return result;
        }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:25,代码来源:GBAGraphics.cs

示例2: GetNormalFormat

        private CanCauseError<Bitmap> GetNormalFormat(byte[] rawPortrait, byte[] rawMini, byte[] rawMouth, Color[] palette)
        {
            int temp;
            var result = new Bitmap(FormatSizePixels.Width, FormatSizePixels.Height, PixelFormat.Format8bppIndexed);
            result.InsertColorsToPalette(palette);

            Bitmap mainPortrait = GBAGraphics.ToBitmap(
                rawPortrait, rawPortrait.Length, 0, palette, this.PortraitSize.Width * TileSize.Width,
                GraphicsMode.Tile4bit, out temp);
            if (temp != this.BlockAdd) return CanCauseError<Bitmap>.Error("Raw mainportrait is wrong size");

            Bitmap miniPortrait;
            if (rawMini != null)
            {
                miniPortrait = GBAGraphics.ToBitmap(
                    rawMini, rawMini.Length, 0, palette, this.MiniSize.Width * TileSize.Width,
                    GraphicsMode.Tile4bit, out temp);
                if (temp != 0) return CanCauseError<Bitmap>.Error("Raw miniportrait is wrong size");
            }
            else miniPortrait = null;

            Bitmap mouthPortrait;
            if (this.SeparateMouthFrames)
            {
                mouthPortrait = GBAGraphics.ToBitmap(
                    rawMouth, rawMouth.Length, 0, palette, this.MouthSize.Width * TileSize.Width,
                    GraphicsMode.Tile4bit, out temp);
                if (temp != 0) return CanCauseError<Bitmap>.Error("Raw mouth is wrong size");
            }
            else
            {
                mouthPortrait = mainPortrait;
            }

            Move(mainPortrait, result, ReverseMapping(this.PictureMapping));
            Move(mouthPortrait, result, ReverseMapping(this.MouthMapping));
            Move(mainPortrait, result, ReverseMapping(this.MiniMapping));
            return result;
        }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:39,代码来源:PortraitFormat.cs

示例3: FromBitmapIndexed

        private static Bitmap FromBitmapIndexed(byte* GBAGraphics, int length, Color[] palette, int width, out int emptyGraphicBlocks)
        {
            int heigth = length / width;
            while (heigth * width < length)
                heigth++;

            emptyGraphicBlocks = length - heigth * width;

            Bitmap result = new Bitmap(width, heigth, PixelFormat.Format8bppIndexed);
            result.InsertColorsToPalette(palette);

            BitmapData bData = result.LockBits(new Rectangle(new Point(), result.Size), ImageLockMode.WriteOnly, result.PixelFormat);

            byte* bitmap = (byte*)bData.Scan0;
            for (int i = 0; i < length; i++)
                bitmap[i] = GBAGraphics[i];

            result.UnlockBits(bData);
            emptyGraphicBlocks = 0;
            return result;
        }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:21,代码来源:GBAGraphics.cs


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