コード例 #1
0
        public static tImageTGA tgaLoad(string pszFilename)
        {
            tImageTGA  _tImageTGA  = null;
            CCFileData cCFileDatum = new CCFileData(pszFilename, "rb");
            ulong      size        = cCFileDatum.Size;

            byte[] buffer = cCFileDatum.Buffer;
            return(_tImageTGA);
        }
コード例 #2
0
 public static void tgaDestroy(tImageTGA psInfo)
 {
     if (psInfo != null)
     {
         if (psInfo.imageData != null)
         {
             psInfo.imageData = null;
         }
         psInfo = null;
     }
 }
コード例 #3
0
ファイル: TGAlib.cs プロジェクト: Openxlive/cocos2d-x-for-xna
        /// <summary>
        /// releases the memory used for the image
        /// </summary>
        /// <param name="psInfo"></param>
        public static void tgaDestroy(tImageTGA psInfo)
        {
            if (psInfo != null)
            {
                if (psInfo.imageData != null)
                {
                    psInfo.imageData = null;
                    //free();
                }

                psInfo = null;
            }
        }
コード例 #4
0
ファイル: TGAlib.cs プロジェクト: Ratel13/cocos2d-x-for-xna
        /// <summary>
        /// load the image header fields. We only keep those that matter!
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static bool tgaLoadHeader(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo)
        {
            bool bRet = false;

            //do
            //{
            //    UInt64 step = sizeof(char) * 2;
            //    if ((step + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }

            //    memcpy(psInfo.type, Buffer + step, sizeof(char));

            //    step += sizeof(char) * 2;
            //    step += sizeof(short) * 4;
            //    if ((step + sizeof(short) * 2 + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }
            //    memcpy(psInfo.width, Buffer + step, sizeof(short));
            //    memcpy(psInfo.height, Buffer + step + sizeof(short), sizeof(short));
            //    memcpy(psInfo.pixelDepth, Buffer + step + sizeof(short) * 2, sizeof(char));

            //    step += sizeof(char);
            //    step += sizeof(short) * 2;
            //    if ((step + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }
            //    char cGarbage;
            //    memcpy(cGarbage, Buffer + step, sizeof(char));

            //    psInfo.flipped = 0;
            //    if (cGarbage & 0x20)
            //    {
            //        psInfo.flipped = 1;
            //    }
            //    bRet = true;
            //} while (0);

            return bRet;
        }
コード例 #5
0
ファイル: TGAlib.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        /// load the image header fields. We only keep those that matter!
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static bool tgaLoadHeader(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo)
        {
            bool bRet = false;

            //do
            //{
            //    UInt64 step = sizeof(char) * 2;
            //    if ((step + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }

            //    memcpy(psInfo.type, Buffer + step, sizeof(char));

            //    step += sizeof(char) * 2;
            //    step += sizeof(short) * 4;
            //    if ((step + sizeof(short) * 2 + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }
            //    memcpy(psInfo.width, Buffer + step, sizeof(short));
            //    memcpy(psInfo.height, Buffer + step + sizeof(short), sizeof(short));
            //    memcpy(psInfo.pixelDepth, Buffer + step + sizeof(short) * 2, sizeof(char));

            //    step += sizeof(char);
            //    step += sizeof(short) * 2;
            //    if ((step + sizeof(char)) > bufSize)
            //    {
            //        break;
            //    }
            //    char cGarbage;
            //    memcpy(cGarbage, Buffer + step, sizeof(char));

            //    psInfo.flipped = 0;
            //    if (cGarbage & 0x20)
            //    {
            //        psInfo.flipped = 1;
            //    }
            //    bRet = true;
            //} while (0);

            return(bRet);
        }
コード例 #6
0
ファイル: TGAlib.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        /// loads the image pixels. You shouldn't call this function directly
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static bool tgaLoadImageData(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo)
        {
            bool bRet = false;

            //do
            //{
            //    int mode, total, i;
            //    char aux;
            //    UInt64 step = (sizeof(char) + sizeof(short)) * 6;

            //    // mode equal the number of components for each pixel
            //    mode = psInfo.pixelDepth / 8;
            //    // total is the number of unsigned chars we'll have to read
            //    total = psInfo.height * psInfo.width * mode;

            //    size_t dataSize = sizeof(char) * total;
            //    if ((step + dataSize) > bufSize)
            //    {
            //        break;
            //    }
            //    memcpy(psInfo.imageData, Buffer + step, dataSize);

            //    // mode=3 or 4 implies that the image is RGB(A). However TGA
            //    // stores it as BGR(A) so we'll have to swap R and B.
            //    if (mode >= 3)
            //    {
            //        for (i = 0; i < total; i += mode)
            //        {
            //            aux = psInfo.imageData[i];
            //            psInfo.imageData[i] = psInfo.imageData[i + 2];
            //            psInfo.imageData[i + 2] = aux;
            //        }
            //    }

            //    bRet = true;
            //} while (0);

            return(bRet);
        }
コード例 #7
0
 /// <summary>
 /// dealloc the map from memory
 /// </summary>
 public void releaseMap()
 {
     m_pTGAInfo         = null;
     m_pPosToAtlasIndex = null;
 }
コード例 #8
0
 /// <summary>
 /// dealloc the map from memory
 /// </summary>
 public void releaseMap()
 {
     m_pTGAInfo = null;
     m_pPosToAtlasIndex = null;
 }
コード例 #9
0
ファイル: TGAlib.cs プロジェクト: Ratel13/cocos2d-x-for-xna
 bool tgaLoadRLEImageData(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo) 
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: TGAlib.cs プロジェクト: Ratel13/cocos2d-x-for-xna
 /// <summary>
 /// converts RGB to greyscale
 /// </summary>
 /// <param name="psInfo"></param>
 public static void tgaRGBtogreyscale(tImageTGA psInfo) 
 {
     throw new NotImplementedException();
 }
コード例 #11
0
ファイル: TGAlib.cs プロジェクト: Ratel13/cocos2d-x-for-xna
        /// <summary>
        /// loads the image pixels. You shouldn't call this function directly
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static bool tgaLoadImageData(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo)
        {
            bool bRet = false;

            //do
            //{
            //    int mode, total, i;
            //    char aux;
            //    UInt64 step = (sizeof(char) + sizeof(short)) * 6;

            //    // mode equal the number of components for each pixel
            //    mode = psInfo.pixelDepth / 8;
            //    // total is the number of unsigned chars we'll have to read
            //    total = psInfo.height * psInfo.width * mode;

            //    size_t dataSize = sizeof(char) * total;
            //    if ((step + dataSize) > bufSize)
            //    {
            //        break;
            //    }
            //    memcpy(psInfo.imageData, Buffer + step, dataSize);

            //    // mode=3 or 4 implies that the image is RGB(A). However TGA
            //    // stores it as BGR(A) so we'll have to swap R and B.
            //    if (mode >= 3)
            //    {
            //        for (i = 0; i < total; i += mode)
            //        {
            //            aux = psInfo.imageData[i];
            //            psInfo.imageData[i] = psInfo.imageData[i + 2];
            //            psInfo.imageData[i + 2] = aux;
            //        }
            //    }

            //    bRet = true;
            //} while (0);

            return bRet;
          
        }
コード例 #12
0
ファイル: TGAlib.cs プロジェクト: liwq-net/liwq718
 bool tgaLoadRLEImageData(byte[] Buffer, UInt64 bufSize, tImageTGA psInfo)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
ファイル: TGAlib.cs プロジェクト: liwq-net/liwq718
 /// <summary>
 /// converts RGB to greyscale
 /// </summary>
 /// <param name="psInfo"></param>
 public static void tgaRGBtogreyscale(tImageTGA psInfo)
 {
     throw new NotImplementedException();
 }
コード例 #14
0
ファイル: TGAlib.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        /// this is the function to call when we want to load an image
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static tImageTGA tgaLoad(string pszFilename)
        {
            int        mode, total;
            tImageTGA  info  = null;
            CCFileData data  = new CCFileData(pszFilename, "rb");
            UInt64     nSize = data.Size;

            byte[] pBuffer = data.Buffer;

            //do
            //{
            //    if (pBuffer == null)
            //    {
            //        break;
            //    }
            //    //info = malloc(sizeof(tImageTGA)) as tImageTGA;

            //    // get the file header info
            //    if (tgaLoadHeader(pBuffer, nSize, info) == null)
            //    {
            //        info.status = (int)TGAEnum.TGA_ERROR_MEMORY;
            //        break;
            //    }

            //    // check if the image is color indexed
            //    if (info.type == 1)
            //    {
            //        info.status = (int)TGAEnum.TGA_ERROR_INDEXED_COLOR;
            //        break;
            //    }

            //    // check for other types (compressed images)
            //    if ((info.type != 2) && (info.type != 3) && (info.type != 10))
            //    {
            //        info.status = (int)TGAEnum.TGA_ERROR_COMPRESSED_FILE;
            //        break;
            //    }

            //    // mode equals the number of image components
            //    mode = info.pixelDepth / 8;
            //    // total is the number of unsigned chars to read
            //    total = info.height * info.width * mode;
            //    // allocate memory for image pixels
            //    // info.imageData = (char[])malloc(sizeof(unsigned char) * total);

            //    // check to make sure we have the memory required
            //    if (info.imageData == null)
            //    {
            //        info.status = (int)TGAEnum.TGA_ERROR_MEMORY;
            //        break;
            //    }

            //    bool bLoadImage = false;
            //    // finally load the image pixels
            //    if (info.type == 10)
            //    {
            //        bLoadImage = tgaLoadRLEImageData(pBuffer,nSize, info);
            //    }
            //    else
            //    {
            //        bLoadImage = tgaLoadImageData(pBuffer, nSize, info);
            //    }

            //    // check for errors when reading the pixels
            //    if (!bLoadImage)
            //    {
            //        info.status = TGAEnum.TGA_ERROR_READING_FILE;
            //        break;
            //    }
            //    info->status = TGA_OK;

            //    if (info->flipped)
            //    {
            //        tgaFlipImage(info);
            //        if (info->flipped)
            //        {
            //            info->status = TGA_ERROR_MEMORY;
            //        }
            //    }
            //} while (0);

            return(info);
        }
コード例 #15
0
 public static bool tgaLoadImageData(byte[] Buffer, ulong bufSize, tImageTGA psInfo)
 {
     return(false);
 }