예제 #1
0
            protected TGA.LINE m_Line;          // ビット配列


            /**--------------------------------------------------------------------------
            * 公開
            *--------------------------------------------------------------------------*/
            /// <summary>
            /// コンストラクタ
            /// </summary>
            public BasePict()
            {
                m_pImage    = null;
                m_ImageSize = 0;
                m_ImageBit  = 0;

                m_pPalette     = null;
                m_PaletteSize  = 0;
                m_PaletteBit   = 0;
                m_PaletteColor = 0;

                m_ImageW = 0;
                m_ImageH = 0;
                m_Line   = TGA.LINE.IMAGE_LINE_LRUD;
            }
예제 #2
0
            public BasePict(BasePict pict)
            {
                m_pImage    = null;
                m_ImageSize = pict.m_ImageSize;
                m_ImageBit  = pict.m_ImageBit;

                m_pPalette     = null;
                m_PaletteSize  = pict.m_PaletteSize;
                m_PaletteBit   = pict.m_PaletteBit;
                m_PaletteColor = pict.m_PaletteColor;

                m_ImageW = pict.m_ImageW;
                m_ImageH = pict.m_ImageH;
                m_Line   = pict.m_Line;
            }
예제 #3
0
            /// <summary>
            /// 指定のビット配列に変換
            /// ※LINEはTGAクラスのものを使用
            /// </summary>
            /// <param name="line">変換するビット配列</param>
            /// <returns>変換の成否</returns>
            public bool ConvertBitType(TGA.LINE line)
            {
                if (line >= TGA.LINE.IMAGE_LINE_MAX)
                {
                    return(false);
                }
                if (m_pImage == null || m_ImageSize == 0)
                {
                    return(false);
                }

                byte srcDiscripter = (byte)((byte)m_Line & 0xf0);
                byte dstDiscripter = (byte)((byte)line & 0xf0);

                // 同じなら処理をしない
                if (srcDiscripter == dstDiscripter)
                {
                    return(true);
                }

                // 配列変換
                try
                {
                    int    tx, ty;
                    int    ofsSrc, ofsDst;
                    byte[] pImage = new byte[m_ImageSize];

                    ofsDst = 0;
                    for (int y = 0; y < m_ImageH; y++)
                    {
                        ty = y;
                        if ((srcDiscripter & 0x20) != (dstDiscripter & 0x20))
                        {
                            // お互いのY方向が一致しないなら反転
                            ty = m_ImageH - y - 1;
                        }

                        for (int x = 0; x < m_ImageW; x++)
                        {
                            tx = x;
                            if ((srcDiscripter & 0x10) != (dstDiscripter & 0x10))
                            {
                                // お互いのX方向が一致しないなら反転
                                tx = m_ImageW - x - 1;
                            }
                            ofsSrc = (ty * m_ImageW) + tx;

                            switch (m_ImageBit)
                            {
                            case 8:
                                pImage[ofsDst++] = m_pImage[ofsSrc];
                                break;

                            case 16:
                                ofsSrc *= 2;
                                byte[] src = BitConverter.GetBytes(BitConverter.ToUInt16(m_pImage, ofsSrc));
                                pImage[ofsDst++] = src[0];
                                pImage[ofsDst++] = src[1];
                                break;

                            case 24:
                                ofsSrc          *= 3;
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                break;

                            case 32:
                                ofsSrc          *= 4;
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                pImage[ofsDst++] = m_pImage[ofsSrc++];
                                break;
                            }
                        }
                    }

                    m_pImage = pImage;
                    m_Line   = (TGA.LINE)(((byte)m_Line & 0x0f) + dstDiscripter);
                }
                catch
                {
                    return(false);
                }

                return(true);
            }