* Fix a couple errors in the rotation code.

This commit is contained in:
Justin Maggard 2012-01-23 18:51:48 +00:00
parent 8298a15490
commit fe581c5e7f
2 changed files with 27 additions and 26 deletions

View File

@ -620,10 +620,10 @@ GetImageMetadata(const char * path, char * name)
rotate = 180;
break;
case 6:
rotate = 270;
rotate = 90;
break;
case 8:
rotate = 90;
rotate = 270;
break;
default:
rotate = 0;

View File

@ -1552,7 +1552,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
char dlna_pn[4];
time_t curtime = time(NULL);
int width=640, height=480, dstw, dsth, size;
long srcw, srch;
int srcw, srch;
unsigned char * data = NULL;
char *path, *file_path;
char *resolution;
@ -1636,9 +1636,31 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
}
DPRINTF(E_INFO, L_HTTP, "Serving resized image for ObjectId: %lld [%s]\n", id, file_path);
switch( rotate )
{
case 90:
ret = sscanf(resolution, "%dx%d", &srch, &srcw);
rotate = ROTATE_90;
break;
case 270:
ret = sscanf(resolution, "%dx%d", &srch, &srcw);
rotate = ROTATE_270;
break;
case 180:
ret = sscanf(resolution, "%dx%d", &srcw, &srch);
rotate = ROTATE_180;
break;
default:
ret = sscanf(resolution, "%dx%d", &srcw, &srch);
rotate = ROTATE_NONE;
break;
}
if( ret != 2 )
{
Send500(h);
return;
}
/* Figure out the best destination resolution we can use */
srcw = strtol(resolution, &saveptr, 10);
srch = strtol(saveptr+1, NULL, 10);
dstw = width;
dsth = ((((width<<10)/srcw)*srch)>>10);
if( dsth > height )
@ -1646,27 +1668,6 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
dsth = height;
dstw = (((height<<10)/srch) * srcw>>10);
}
switch( rotate )
{
case 90:
rotate = dsth;
dsth = dstw;
dstw = rotate;
rotate = ROTATE_90;
break;
case 270:
rotate = dsth;
dsth = dstw;
dstw = rotate;
rotate = ROTATE_270;
break;
case 180:
rotate = ROTATE_180;
break;
default:
rotate = ROTATE_NONE;
break;
}
if( dstw <= 640 && dsth <= 480 )
strcpy(dlna_pn, "SM");