~haggai-eran/nux/rtl-rebased

« back to all changes in this revision

Viewing changes to NuxImage/Tga.cpp

  • Committer: Jay Taoko
  • Date: 2011-10-21 22:06:35 UTC
  • mto: This revision was merged to the branch mainline in revision 509.
  • Revision ID: jay.taoko@canonical.com-20111021220635-1tdvncs47hdlfbz1
* Removed custom Nux types: t_u32, t_s32, t_bool, ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
  {
49
49
    std::ifstream fileStream;
50
50
    BYTE *tga_buffer, *tga_data_pointer;
51
 
    t_u32 datasize;
 
51
    unsigned int datasize;
52
52
 
53
53
    tga_header header;
54
54
    tga_footer footer;
55
 
    t_u32 rle, footer_present;
 
55
    unsigned int rle, footer_present;
56
56
 
57
57
    if (!GFileManager.FileExist(file_name))
58
58
    {
69
69
    }
70
70
 
71
71
    fileStream.seekg( 0, std::ios::end);
72
 
    t_u32 filesize = fileStream.tellg();
 
72
    unsigned int filesize = fileStream.tellg();
73
73
    fileStream.seekg( 0, std::ios::beg);
74
74
 
75
75
 
169
169
      return 0;
170
170
    }
171
171
 
172
 
    t_u32 width, height;
 
172
    unsigned int width, height;
173
173
    width  = header.width_hi << 8 |  header.width_lo;
174
174
    height = header.height_hi << 8 | header.height_lo;
175
175
 
219
219
 
220
220
    tga_data_pointer = tga_buffer;
221
221
 
222
 
    t_u32 image_width = TextureObjectData->GetSurface(0).GetWidth();
223
 
    t_u32 image_height = TextureObjectData->GetSurface(0).GetHeight();
 
222
    unsigned int image_width = TextureObjectData->GetSurface(0).GetWidth();
 
223
    unsigned int image_height = TextureObjectData->GetSurface(0).GetHeight();
224
224
 
225
225
    if (rle == 0)
226
226
    {
227
 
      t_u32 j, i;
228
 
      t_u32 position = 0;
229
 
      t_u32 value;
 
227
      unsigned int j, i;
 
228
      unsigned int position = 0;
 
229
      unsigned int value;
230
230
 
231
231
      for (j = 0; j < image_height; j++)
232
232
      {
303
303
      UINT value;
304
304
      //unsigned BYTE *last_byte = buf_dest + 4*image->height*image->width; // last byte of destination image
305
305
 
306
 
      t_u32 size = TextureObjectData->GetSurface(0).GetWidth() * TextureObjectData->GetSurface(0).GetHeight();
 
306
      unsigned int size = TextureObjectData->GetSurface(0).GetWidth() * TextureObjectData->GetSurface(0).GetHeight();
307
307
 
308
308
      while (position < size)
309
309
      {
310
 
        t_u32 repetition_count = (*tga_data_pointer & 0x7f) + 1;
 
310
        unsigned int repetition_count = (*tga_data_pointer & 0x7f) + 1;
311
311
 
312
312
        if (*tga_data_pointer & 0x80) // RLE Packet
313
313
        {
545
545
  {
546
546
    std::fstream fileStream;
547
547
 
548
 
    t_u32 datasize;
 
548
    unsigned int datasize;
549
549
    tga_header header;
550
550
    tga_footer footer;
551
551
 
570
570
      return HR_FILE_IO_FAIL;
571
571
    }
572
572
 
573
 
    t_u32 BPP = 3;
 
573
    unsigned int BPP = 3;
574
574
 
575
575
    if (image->GetSurface(0).GetFormat() == BITFMT_R8G8B8 ||
576
576
        image->GetSurface(0).GetFormat() == BITFMT_B8G8R8)
650
650
    fileStream.write((char *) &header.bpp,                 sizeof(header.bpp));
651
651
    fileStream.write((char *) &header.descriptor,          sizeof(header.descriptor));
652
652
 
653
 
    t_s32 i, j;
 
653
    int i, j;
654
654
 
655
655
    for (j = 0; j < image->GetSurface(0).GetHeight(); j++)
656
656
    {
657
657
      for (i = 0; i < image->GetSurface(0).GetWidth(); i++)
658
658
      {
659
 
        t_u32 gba = image->GetSurface(0).Read(i, j);
 
659
        unsigned int gba = image->GetSurface(0).Read(i, j);
660
660
        fileStream.write((char *) &gba, BPP);
661
661
      }
662
662
    }