示例#1
0
文件: tga.cs 项目: tsu-kunn/TGA
            /// <summary>
            /// TGAヘッダーの読み込み
            /// </summary>
            /// <param name="pSrc">画像データ</param>
            /// <param name="offset">ヘッダーまでのオフセット</param>
            /// <returns>true:読み込み成功</returns>
            public bool ReadHeader(byte[] pSrc, int offset)
            {
                if (pSrc == null)
                {
                    return(false);
                }

                int ofs = offset;

                IDField      = pSrc[ofs++];
                usePalette   = pSrc[ofs++];
                imageType    = pSrc[ofs++];
                paletteIndex = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                paletteColor = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                paletteBit   = pSrc[ofs++];
                imageX       = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                imageY       = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                imageW       = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                imageH       = BitConverter.ToUInt16(pSrc, ofs); ofs += sizeof(ushort);
                imageBit     = pSrc[ofs++];
                discripter   = pSrc[ofs++];

                // DEBUG:サイズチェック
                string str = "TGAヘッダーサイズエラー" + ofs + " == " + HEADER_SIZE + "\n";

                System.Diagnostics.Debug.Assert(ofs == HEADER_SIZE, str);

                return(TGA.CheckSupport(this));
            }