[Scummvm-cvs-logs] SF.net SVN: scummvm:[42220] scummvm/branches/gsoc2009-16bit/graphics/jpeg. cpp
scott_t at users.sourceforge.net
scott_t at users.sourceforge.net
Tue Jul 7 16:04:18 CEST 2009
Revision: 42220
http://scummvm.svn.sourceforge.net/scummvm/?rev=42220&view=rev
Author: scott_t
Date: 2009-07-07 14:04:18 +0000 (Tue, 07 Jul 2009)
Log Message:
-----------
Properly handle odd-sized JPEG files (ie, those not a multiple of 8 pixels)
Modified Paths:
--------------
scummvm/branches/gsoc2009-16bit/graphics/jpeg.cpp
Modified: scummvm/branches/gsoc2009-16bit/graphics/jpeg.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/jpeg.cpp 2009-07-07 13:39:24 UTC (rev 42219)
+++ scummvm/branches/gsoc2009-16bit/graphics/jpeg.cpp 2009-07-07 14:04:18 UTC (rev 42220)
@@ -354,6 +354,13 @@
// Read all the scan MCUs
uint16 xMCU = _w / (_maxFactorH * 8);
uint16 yMCU = _h / (_maxFactorV * 8);
+
+ // Check for non- multiple-of-8 dimensions
+ if (_w % 8 != 0)
+ xMCU++;
+ if (_h % 8 != 0)
+ yMCU++;
+
bool ok = true;
for (int y = 0; ok && (y < yMCU); y++)
for (int x = 0; ok && (x < xMCU); x++)
@@ -478,12 +485,21 @@
// Convert coordinates from MCU blocks to pixels
x <<= 3;
y <<= 3;
- for (int j = 0; j < 8; j++) {
+
+ // Handle non- multiple-of-8 dimensions
+ byte xLim = 8;
+ byte yLim = 8;
+ if (x*scalingH + 8 > _w)
+ xLim -= (x*scalingH + 8 - _w);
+ if (y*scalingV + 8 > _h)
+ yLim -= (y*scalingV + 8 - _h);
+
+ for (int j = 0; j < yLim; j++) {
for (int sV = 0; sV < scalingV; sV++) {
// Get the beginning of the block line
byte *ptr = (byte *)_currentComp->surface.getBasePtr(x * scalingH, (y + j) * scalingV + sV);
- for (int i = 0; i < 8; i++) {
+ for (int i = 0; i < xLim; i++) {
for (uint8 sH = 0; sH < scalingH; sH++) {
*ptr = (byte)(result[j * 8 + i]);
ptr++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list