Post by Adam on Dec 10, 2009 17:37:27 GMT -5
using the stdio header i am reading a the image file into memory as the characters
then i am getting my data from the memblock array as
which all works just fine except for one of the imageSpec values returns wrong but its not important (x or y origin i think). but when i try
pixelData[0] for instance returns -1 (its supposed to return 255 with the certain file) and since this is the main part of the image loader non of it really works without this.
Here is a screen shot loading 'sample.tga' with this faulty loader and rendering it with my glspriteloader (about 60A% ported becase i don't feel the need to finish it until i get at least one image loader written)
EDIT:\
I personally think its type casting issues but still have no idea how to fix it, i would love if someone could help me fix my problem
ifstream file (filename, ios::binary | ios::ate);
if (!file.is_open()) return 0;
ifstream::pos_type size = file.tellg();
char *memblock = new char[size];
file.seekg(0,ios::beg);
file.read(memblock, size);
file.close();
then i am getting my data from the memblock array as
tga.idField = memblock[0];
tga.colorMapType = memblock[1];
tga.imageType = memblock[2];
for (int i = 0; i < 5;i++) {
tga.colorMapSpec[i] = memblock[i+3];
}
tga.imageSpec[0] = memblock[8] + memblock[9];
tga.imageSpec[1] = memblock[10] + memblock[11];
tga.imageSpec[2] = memblock[12] + memblock[13];
tga.imageSpec[3] = memblock[14] + memblock[15];
which all works just fine except for one of the imageSpec values returns wrong but its not important (x or y origin i think). but when i try
int *pixelData = new int[byteSize];
if (tga.imageType = 2) {
for (int i=0;i < byteSize; i++) {
pixelData[i] = memblock[i+18];
}
}
pixelData[0] for instance returns -1 (its supposed to return 255 with the certain file) and since this is the main part of the image loader non of it really works without this.
Here is a screen shot loading 'sample.tga' with this faulty loader and rendering it with my glspriteloader (about 60A% ported becase i don't feel the need to finish it until i get at least one image loader written)
EDIT:\
I personally think its type casting issues but still have no idea how to fix it, i would love if someone could help me fix my problem