本文整理匯總了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;
}