本文整理汇总了C#中System.Drawing.Bitmap.IsIndexed方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.IsIndexed方法的具体用法?C# Bitmap.IsIndexed怎么用?C# Bitmap.IsIndexed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Bitmap
的用法示例。
在下文中一共展示了Bitmap.IsIndexed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeTPLTextureIndexed
public virtual FileMap EncodeTPLTextureIndexed(Bitmap src, int mipLevels, WiiPaletteFormat format, out FileMap paletteFile)
{
if (!src.IsIndexed())
throw new ArgumentException("Source image must be indexed.");
FileMap texMap = EncodeTPLTexture(src, mipLevels);
paletteFile = EncodeTPLPalette(src.Palette, format);
return texMap;
}
示例2: EncodeTPLTexture
public virtual FileMap EncodeTPLTexture(Bitmap src, int mipLevels)
{
int w = src.Width, h = src.Height;
int bw = BlockWidth, bh = BlockHeight;
PixelFormat fmt = src.IsIndexed() ? src.PixelFormat : PixelFormat.Format32bppArgb;
FileMap fileView = FileMap.FromTempFile(GetFileSize(w, h, mipLevels) + TPLTextureHeader.Size);
try
{
//Build TPL header
TPLTextureHeader* tex = (TPLTextureHeader*)fileView.Address;
tex->_wrapS = 0;
tex->_wrapT = 0;
tex->_minFilter = 1;
tex->_magFilter = 1;
tex->_minLOD = 0;
tex->_maxLOD = (short)(mipLevels - 1);
tex->PixelFormat = RawFormat;
tex->_width = (ushort)w;
tex->_height = (ushort)h;
tex->_data = TPLTextureHeader.Size;
int sStep = bw * Image.GetPixelFormatSize(fmt) / 8;
int dStep = bw * bh * BitsPerPixel / 8;
VoidPtr baseAddr = fileView.Address;
using (DIB dib = DIB.FromBitmap(src, bw, bh, fmt))
for (int i = 1; i <= mipLevels; i++)
EncodeLevel(baseAddr + tex->_data, dib, src, dStep, sStep, i);
return fileView;
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
fileView.Dispose();
return null;
}
}
示例3: EncodeREFTTextureIndexed
public virtual FileMap EncodeREFTTextureIndexed(Bitmap src, int mipLevels, WiiPaletteFormat format)
{
if (!src.IsIndexed())
throw new ArgumentException("Source image must be indexed.");
return EncodeREFTTexture(src, mipLevels, format);
}
示例4: EncodeTEX0Texture
public virtual FileMap EncodeTEX0Texture(Bitmap src, int mipLevels)
{
int w = src.Width, h = src.Height;
int bw = BlockWidth, bh = BlockHeight;
PixelFormat fmt = src.IsIndexed() ? src.PixelFormat : PixelFormat.Format32bppArgb;
FileMap fileView = FileMap.FromTempFile(GetFileSize(w, h, mipLevels) + 0x40);
try
{
//Build TEX header
TEX0v1* header = (TEX0v1*)fileView.Address;
*header = new TEX0v1(w, h, RawFormat, mipLevels);
int sStep = bw * Image.GetPixelFormatSize(fmt) / 8;
int dStep = bw * bh * BitsPerPixel / 8;
using (DIB dib = DIB.FromBitmap(src, bw, bh, fmt))
for (int i = 1; i <= mipLevels; i++)
EncodeLevel(header->PixelData, dib, src, dStep, sStep, i);
return fileView;
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
fileView.Dispose();
return null;
}
}
示例5: EncodeREFTTexture
public virtual FileMap EncodeREFTTexture(Bitmap src, int mipLevels, WiiPaletteFormat format)
{
int w = src.Width, h = src.Height;
int bw = BlockWidth, bh = BlockHeight;
ColorPalette pal = src.Palette;
PixelFormat fmt = src.IsIndexed() ? src.PixelFormat : PixelFormat.Format32bppArgb;
FileMap fileView = FileMap.FromTempFile(GetFileSize(w, h, mipLevels) + 0x20 + (pal != null ? (pal.Entries.Length * 2) : 0));
try
{
//Build REFT image header
REFTImageHeader* header = (REFTImageHeader*)fileView.Address;
*header = new REFTImageHeader((ushort)w, (ushort)h, (byte)RawFormat, (byte)format, (ushort)(pal != null ? pal.Entries.Length : 0), (uint)fileView.Length - 0x20 - (uint)(pal != null ? (pal.Entries.Length * 2) : 0), (byte)(mipLevels - 1));
int sStep = bw * Image.GetPixelFormatSize(fmt) / 8;
int dStep = bw * bh * BitsPerPixel / 8;
using (DIB dib = DIB.FromBitmap(src, bw, bh, fmt))
for (int i = 1; i <= mipLevels; i++)
EncodeLevel((VoidPtr)header + 0x20, dib, src, dStep, sStep, i);
if (pal != null)
{
int count = pal.Entries.Length;
switch (format)
{
case WiiPaletteFormat.IA8:
{
IA8Pixel* dPtr = (IA8Pixel*)header->PaletteData;
for (int i = 0; i < count; i++)
dPtr[i] = (IA8Pixel)pal.Entries[i];
break;
}
case WiiPaletteFormat.RGB565:
{
wRGB565Pixel* dPtr = (wRGB565Pixel*)header->PaletteData;
for (int i = 0; i < count; i++)
dPtr[i] = (wRGB565Pixel)pal.Entries[i];
break;
}
case WiiPaletteFormat.RGB5A3:
{
wRGB5A3Pixel* dPtr = (wRGB5A3Pixel*)header->PaletteData;
for (int i = 0; i < count; i++)
dPtr[i] = (wRGB5A3Pixel)pal.Entries[i];
break;
}
}
}
return fileView;
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
fileView.Dispose();
return null;
}
}