00001
00002
00003 #include <fs/ras/fsRle8Enc.h>
00004 #include <fs/ras/fsRle8Blt.h>
00005
00006 #include <stdio.h>
00007 #include <memory.h>
00008 #include <cassert>
00009
00011 const fs::ras::nsRle8Blt::PxFmt8888_t *
00012 Conv(const fs::ras::Rle8Enc_t::PxFmt8888_t *pFrom)
00013 {
00014
00015 return reinterpret_cast<const fs::ras::nsRle8Blt::PxFmt8888_t *>(pFrom);
00016 }
00017
00018 int main()
00019 {
00020 using namespace fs::ras;
00021
00022
00023 const Rle8Enc_t::PxFmt8888_t aIn[] = {
00024 {0,0,0,0}, {0,0,255,128}, {0,0,0,0},
00025 {0,255,0,128}, {255,0,0,255}, {0,255,0,128},
00026 {0,0,255,128}, {0,0,255,128}, {0,0,0,0},
00027 };
00028
00029
00030 Rle8Enc_t Rle(aIn, 3, 3);
00031 assert(Rle.IsValid() && "Couldn't encode image data!");
00032
00033
00034 int nW = 0, nH = 0;
00035 Rle.GetSize(nW, nH);
00036 ::printf("image width = %d, image height = %d\n", nW, nH);
00037
00038
00039 const unsigned char *pRle = 0;
00040 int nRleNum = 0;
00041 Rle.GetRle(pRle, nRleNum);
00042 ::printf("RLE8 data stream: ");
00043 for(int i = 0; i < nRleNum; ++i)
00044 {
00045 bool bTr = (pRle[i] & 1) == 0;
00046 int nNum = pRle[i] >> 1;
00047
00048 ::printf("%d{%d/%d} ", pRle[i], !bTr, nNum);
00049
00050 if(!bTr)
00051 for(int j = 0; j < nNum; ++i, ++j)
00052 ::printf("%d ", pRle[i + 1]);
00053
00054 }
00055 ::printf("\n");
00056
00057
00058 const Rle8Enc_t::PxFmt8888_t *pPal = 0;
00059 int nPalNum = 0;
00060 Rle.GetPal(pPal, nPalNum);
00061 ::printf("palette items: ");
00062 for(int i = 0; i < nPalNum; ++i)
00063 {
00064 ::printf("%d-%d-%d-%d ",
00065 pPal[i].r, pPal[i].g, pPal[i].b, pPal[i].a);
00066 }
00067 ::printf("\n");
00068
00069
00070 const Rle8Enc_t::uint32 *pOff = 0;
00071 int nOffNum = 0;
00072 Rle.GetOff(pOff, nOffNum);
00073 ::printf("line offsets: ");
00074 for(int i = 0; i < nOffNum; ++i)
00075 ::printf("%d ", pOff[i]);
00076 ::printf("\n---\n");
00077
00078
00079 nsRle8Blt::PxFmt8888_t aOut[sizeof(aIn)];
00080 ::memset(aOut, 0, sizeof(aOut));
00081
00082 Rle8Blt<nsRle8Blt::Cl8888TrCpPcy_t>(
00083 pRle, Conv(pPal), pOff,
00084 3, 3,
00085 3, 3,
00086 aOut,
00087 3, 3,
00088 0, 0
00089 );
00090
00091
00092 ::printf("aIn %s aOut\n", ::memcmp(aIn, aOut, sizeof(aIn)) == 0 ?
00093 "==" : "!=");
00094
00095 return 0;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104