Actions
Feature #1606
closedWPainter::Image support for image/jpeg
Status:
Closed
Priority:
Low
Assignee:
Michael Vilsker
Target version:
-
Start date:
12/15/2012
Due date:
% Done:
0%
Estimated time:
Description
In WPainter::Image::Image(const std::string& uri, const std::string& fileName), you can state a fileName to obtain image width and height. Only image/png and image/gif are supported. This code would add support for image/jpeg. Sorry it is not an actual patch, but should be pretty straightforward to implement:
First you have to make some seeks through the file. Here buf is the fread buffer (you call it header in your code) and f is the jpeg file.
if(mimeType == "image/jpeg") {
long pos=2;
while (buf[2]==0xFF) {
if (buf[3]==0xC0 || buf[3]==0xC1 || buf[3]==0xC2 || buf[3]==0xC3 || buf[3]==0xC9 || buf[3]==0xCA || buf[3]==0xCB) break;
pos += 2+(buf[4]<<8)+buf[5];
if (pos+12>len) break;
fseek(f,pos,SEEK_SET);
fread(buf+2,1,12,f);
}
}
After this, where you compute height and width for gif and png formats, you should add
else if(mimeType == "image/jpeg") {
y = (buf[7]<<8) + buf[8];
x = (buf[9]<<8) + buf[10];
}
And that's it.
Regards
Updated by Koen Deforche over 11 years ago
- Status changed from New to InProgress
- Assignee set to Michael Vilsker
Hey Michael,
Can you take a look at this, and test it ?
Regards,
koen
Updated by Michael Vilsker almost 10 years ago
- Status changed from InProgress to Resolved
Updated by Koen Deforche over 9 years ago
- Status changed from Resolved to Closed
Actions