135 {
136
138 const bool swapFlag = std::endian::native == std::endian::little;
140 if (!image) {
141 fprintf(stderr, "Out of memory!\n");
143 }
144 if (!(
image->file = fopen(fileName,
"rb"))) {
145 perror(fileName);
148 }
149
150 int bytesRead = fread(image, 1, 12,
image->file);
151
152 if (bytesRead != 12) {
153 fprintf(stderr, "fread failed!\n");
156 return nullptr;
157 }
158
159
160
161
162
163 if (swapFlag) {
164 image->imagic = std::byteswap (
image->imagic);
170 }
171
172
173 const unsigned int colourBuffSize=
image->xsize*256u;
175 image->tmpR = ucharAddress(
malloc(colourBuffSize));
176 image->tmpG = ucharAddress(
malloc(colourBuffSize));
177 image->tmpB = ucharAddress(
malloc(colourBuffSize));
178 if (
image->tmp == NULL ||
image->tmpR == NULL ||
image->tmpG == NULL ||
179 image->tmpB == NULL) {
180 fprintf(stderr, "Out of memory!\n");
182 }
183
184
185 if ((
image->type & 0xFF00) == 0x0100) {
186 size_t x = ((size_t)
image->ysize * (size_t)
image->zsize) *
sizeof(
unsigned);
187
188
191 if (
image->rowStart == NULL ||
image->rowSize == NULL) {
192 fprintf(stderr, "Out of memory!\n");
194 }
195 image->rleEnd = 512 + (2 *
x);
196 const int fseekRetVal= fseek(
image->file, 512, SEEK_SET);
197 if (fseekRetVal !=0){
198 fprintf(stderr, "Something very wrong with fseek near line 205 of VP1QtInventorUtils.cxx");
199 }
200 size_t bytesRead = 0;
201 bytesRead = fread(
image->rowStart, 1,
x,
image->file);
203 bytesRead = fread(
image->rowSize, 1,
x,
image->file);
205
206 if (swapFlag) {
209 }
210 } else {
211 image->rowStart = NULL;
212 image->rowSize = NULL;
213 }
215 }
struct VP1QtInventorUtils::Imp::_ImageRec ImageRec
static void ConvertLong(unsigned *array, long length)