當前位置: 首頁>>代碼示例>>C#>>正文


C# Bitmap.IsIndexed方法代碼示例

本文整理匯總了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;
        }
開發者ID:blahblahblahblah831,項目名稱:brawltools2,代碼行數:9,代碼來源:TextureConverter.cs

示例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;
            }
        }
開發者ID:blahblahblahblah831,項目名稱:brawltools2,代碼行數:40,代碼來源:TextureConverter.cs

示例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);
        }
開發者ID:blahblahblahblah831,項目名稱:brawltools2,代碼行數:7,代碼來源:TextureConverter.cs

示例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;
            }
        }
開發者ID:blahblahblahblah831,項目名稱:brawltools2,代碼行數:30,代碼來源:TextureConverter.cs

示例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;
            }
        }
開發者ID:blahblahblahblah831,項目名稱:brawltools2,代碼行數:62,代碼來源:TextureConverter.cs


注:本文中的System.Drawing.Bitmap.IsIndexed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。