本文整理汇总了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;
}
示例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;
}
示例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;
}