Fixed Leaf .mos files wrong orientation and colors

on behalf of Torger, see issue 1327
This commit is contained in:
Oliver Duis
2012-04-21 10:04:27 +02:00
parent 6c78b241f5
commit 2727956b19
2 changed files with 34 additions and 3 deletions

View File

@@ -306,10 +306,39 @@ void fclose (IMFILE* f) {
}
int fscanf (IMFILE* f, const char* s ...) {
// fscanf not easily wrapped since we have no terminating \0 at end
// of file data and vsscanf() won't tell us how many characters that
// were parsed. However, only dcraw.cc code use it and only for "%f" and
// "%d", so we make a dummy fscanf here just to support dcraw case.
char buf[50], *endptr;
int copy_sz = f->size - f->pos;
if (copy_sz > sizeof(buf)) {
copy_sz = sizeof(buf) - 1;
}
memcpy(buf, &f->data[f->pos], copy_sz);
buf[copy_sz] = '\0';
va_list ap;
va_start (ap, s);
if (strcmp(s, "%d") == 0) {
int i = strtol(buf, &endptr, 10);
if (endptr == buf) {
return 0;
}
int *pi = va_arg(ap, int*);
*pi = i;
} else if (strcmp(s, "%f") == 0) {
float f = strtof(buf, &endptr);
if (endptr == buf) {
return 0;
}
float *pf = va_arg(ap, float*);
*pf = f;
}
va_end (ap);
f->pos += endptr - buf;
return 1;
}
va_list ap;
return sscanf (f->data, s, ap);
}
char* fgets (char* s, int n, IMFILE* f) {

View File

@@ -156,6 +156,8 @@ int RawImage::loadRaw (bool loadData, bool closeFile)
this->rotate_deg = 180;
else if (flip==6)
this->rotate_deg = 90;
else if (flip % 90 == 0 && flip < 360)
this->rotate_deg = flip;
else
this->rotate_deg = 0;