Click to See Complete Forum and Search --> : gdi+ drawImage scaling bug 2
drew_canitz
August 22nd, 2007, 04:48 PM
Let me try to ask my question a different way.
Both of these JPEG files are 640x480.
http://family.canitzdomain.com/images/07_05_06_Alex733.JPG
http://family.canitzdomain.com/images/06_06_06_Alex274.JPG
Why does the 733 one render larger than the other using the following code snippet?
Bitmap bm1( L"07_05_06_Alex733.JPG" );
Bitmap bm2( L"06_06_06_Alex274.JPG" );
Graphics graphics( hWnd );
graphics.DrawImage( &bm1, 0, 0 );
graphics.DrawImage( &bm2, 0, 0 );
If they're the same size, then the 733 should be completely obsured by the second DrawImage. But it's not. Any ideas?
Can anyone at least confirm that they get the same results?
Thanks!
VladimirF
August 22nd, 2007, 08:33 PM
Can anyone at least confirm that they get the same results?Well, that's easy - I do get the same results...
Also, even when I change the order - your image Alex733.jpg still comes up big. (I thought that there might be some initialization issues).
I was even looking at file properties in PhotoShop - can't see the difference.
The resolution looks the same, size, units, etc.
You need a JPEG guru to tell you what's wrong.
VladimirF
August 22nd, 2007, 08:57 PM
After looking some more into files properties I noticed that they were "touched" by different versions of Picasa. The "bad" one has references to Picasa 3.0 and 2.7. Are any of these in Beta? :)
Do you have original jpegs from the camera? Do they work OK?
drew_canitz
August 23rd, 2007, 09:56 AM
Yes, you're exactly right. I didn't notice this problem until I got the latest Picasa. It's a free image editing tool from Google. It's not beta, but it's obviously different.
I did a lot more digging into JPEGs than I thought I ever would, but I didn't get very far.
I got an EXIF viewer plug in for Firefox. The only differences I see there are that the new image includes a thumbnail and has a corrected "Interoperability Index".
I then started to learn about JPEG file headers and found that the most common format is actually JFIF, which both of these images are. Other than the fact that the more recent one has a thumbnail, I don't see any obvious differences.
Obviously there's something there that I'm missing. Either my tools aren't showing me what's different or I don't understand how GDI+ is supposed to work.
I no longer have the original images. I will follow up with that thought when I have new pictures in the future.
You said I might need a JPEG guru. Do you know which rock I have to look under to find some?
Thanks! :)
Drew
drew_canitz
August 23rd, 2007, 03:57 PM
Too bad Microsoft didn't put this in the DrawImage documentation.
"If you don’t specify a height and width when you call Graphics::DrawImage, GDI+ calculates them based on the screen’s DPI and the image’s DPI."
http://msdn2.microsoft.com/en-us/library/ms969894.aspx
My old image's dpi was the same as the screen (96 pixels/inch) so it rendered exactly as large as it said it was. The new image's dpi is the usual image dpi (72 pixels/inch). So the new image was 96/72 or 4/3 the size I was expecting.
Oh, and bitmap.SetResolution( 96.0f, 96.0f ) succeeds, but fails when you then try to draw it with an "InvalidParameter" status code. Super.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.