-
July 26th, 2016, 01:13 AM
#1
CImage reverse dimension cx<->cy !
Only if i load pics taken vertically (so what width is < of height).
Example: Pic “strFoto” have width of 1000px and height of 3000px.
CImage img;
img.Load(strFoto);
int cx = img.GetWidth(); // return 3000!!!!
int cy = img.GetHeight();// return 1000!!!
Some advice please
Thanks
-
July 26th, 2016, 04:57 AM
#2
Re: CImage reverse dimension cx<->cy !
Are you sure that your image is not corrupt or incomplete? Can you share it?
-
July 26th, 2016, 05:38 AM
#3
Re: CImage reverse dimension cx<->cy !
Hi TubularX,
Yes i m shure.
I did tests with pics from Windows Phone and Samsung S4 but is equal...and I see "right" is on Smartphones and Windows but Cimage return reverse!
However if I open with Paint and save with other name these apparently equal work with CImage.
I enclose a photo.
Thank U.
-
July 26th, 2016, 06:11 AM
#4
Re: CImage reverse dimension cx<->cy !
As you see the photo is taken vertically, although well here you see horizontal as with CImage, while various viewers on Windows and even the simple Paint the show correctly.
Thanks
-
July 26th, 2016, 06:29 AM
#5
Re: CImage reverse dimension cx<->cy !
I tried with the file "WP_20160403_15_42_25_Pro.jpg" that you shared.
The result is as expected:
cx: 600
cy: 338
However, the width is not less than the height in the image you enclosed!
Of course, based on the motive, a human might argue that the width and height are reversed.
But to the computer, the width is always just a range of pixels in the x-axis and the height in y-axis.
-
July 26th, 2016, 06:37 AM
#6
Re: CImage reverse dimension cx<->cy !
even the simple Paint the show correctly.
Paint also shows it as 600 x 338...
-
July 26th, 2016, 06:38 AM
#7
Re: CImage reverse dimension cx<->cy !
Hold on...the original photo has
cx: 1728
cy: 3072
As you can see below
-
July 26th, 2016, 06:39 AM
#8
Re: CImage reverse dimension cx<->cy !
I think the site that compresses
-
July 26th, 2016, 06:42 AM
#9
Re: CImage reverse dimension cx<->cy !
OK, then there's probably some orientation metadata in your original jpg file.
Check this out:
http://stackoverflow.com/questions/5...ation-metadata
Edit: Sorry, I just noticed the examples above are in Java. I guess you need a C++ solution. I'm not sure how to deal with it using CImage, but I found a solution with QT: http://imonad.com/photo/jpeg-exif-orientation/
Edit #2: It's also possible with GDI+: https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
Last edited by TubularX; July 26th, 2016 at 07:11 AM.
-
July 26th, 2016, 07:03 AM
#10
Re: CImage reverse dimension cx<->cy !
You think so too ... I think anyone doing a test with your smartphone to have my problema.....io I tried with Windows Phone with Samsung and equals.
I read a bit of the link and is pretty much the same thing
... though that absurd thing ☺
thank you
Hello.
-
July 28th, 2016, 12:46 PM
#11
[RESOLVED] CImage reverse dimension cx<->cy !
Then ... the problem is just the orientation of the images inserted in the Exif file format
So would process all the Exif, but, looking at Exif (and trying) I found that:
If Big-Endian (Motorola) encoding file (like on Windows Phone) the byte to 0x38 identifies the orientation, while for Little Endian (Intel) (as on Samsung) byte is 0x4F.
Of the 8 possible values of expected orientation, in my case I need only 3:
If that byte==3 means that the image is rotate of 180.
If that byte==6 means that the image is rotate of 90CW.
If that byte==8 means that the image is rotate of 270CW.
The rest in my case is not interesting …then I avoid to process all the Exif, do I hurt???
Code sample:
unsigned char b[0x4F]
CFile f(filename, CFile::modeRead);
f.Read(b, sizeof(b) );
unsigned char ucRotate = 0;
// Is a Exif file format?
if (b[0]==0xFF && b[1]==0xD8 && b[2]==0xFF &&
b[3]==0xE1 && b[6]==’E’ && b[7]==’x’ && b[8]==’i’ && b[9]==’f’)
{
// is a Big Endian?
if (b[0xC]==’M’ && b[0xD]==’M’)
{
ucRotate=b[0x37];
}
// is a Little Endian?
if (b[0xC]==’I’ && b[0xD]==’I’)
{
ucRotate=b[0x4E];
}
}
f.close();
…
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|