Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » JPEG Images do not get rotated correctly
Re: JPEG Images do not get rotated correctly [message #50369 is a reply to message #50367] |
Thu, 04 October 2018 11:28 |
Oblivion
Messages: 1093 Registered: August 2007
|
Senior Contributor |
|
|
Hello Tom,
There seems to be support for EXIF rotation in U++, jpeg plugin, but I think its usage is -reasonably, IMO- left to client code.
See plugin/jpg/jpgupp.cpp, ln: 341, 343 (JpegRaster:Data:ExifDir):
if(type == BASE_IFD) {
if(tag == 0x112)
metadata.Add("orientation", Exif16(data));
Now, I did not test this yet, as I rarely work with jpg images directly, but it should be possible to extract the information using JpegRaster::GetMetaData("orientation").
Edit: Ok, I've tested it and it works with ImageView too:
void ImageView::Load(const char *filename)
{
img.SetImage(Null);
FileIn in(filename);
One<StreamRaster> r = StreamRaster::OpenAny(in);
if(!r)
return;
JPGRaster *jpg = dynamic_cast<JPGRaster*>(~r);
if(jpg) {
DUMP(jpg->GetMetaData("orientation")); // will return "3" for the image you've provided.
}
Size rsz = img.GetSize();
Size isz = r->GetSize();
if(isz.cx >= rsz.cx || isz.cy >= rsz.cy) {
if(isz.cx * rsz.cx < rsz.cy * isz.cy)
rsz.cx = isz.cx * rsz.cy / isz.cy;
else
rsz.cy = isz.cy * rsz.cx / isz.cx;
ImageEncoder m;
Rescale(m, rsz, *r, isz);
img.SetImage(m);
}
else
img.SetImage(r->GetImage());
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 04 October 2018 12:55] Report message to a moderator
|
|
|
|
|
JPEG Images do not get rotated correctly
By: Tom1 on Mon, 01 October 2018 11:01
|
|
|
Re: JPEG Images do not get rotated correctly
By: Zbych on Wed, 03 October 2018 19:32
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 08:58
|
|
|
Re: JPEG Images do not get rotated correctly
By: Oblivion on Thu, 04 October 2018 11:28
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 14:03
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 14:33
|
|
|
Re: JPEG Images do not get rotated correctly
By: Oblivion on Thu, 04 October 2018 18:13
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 19:05
|
|
|
Re: JPEG Images do not get rotated correctly
By: mirek on Wed, 10 October 2018 13:20
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Wed, 10 October 2018 13:28
|
|
|
Re: JPEG Images do not get rotated correctly
By: mirek on Fri, 12 October 2018 19:09
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Fri, 12 October 2018 20:40
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Fri, 12 October 2018 21:21
|
|
|
Re: JPEG Images do not get rotated correctly
By: mirek on Sat, 13 October 2018 19:07
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Sat, 13 October 2018 22:33
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Sun, 21 October 2018 16:20
|
|
|
Re: JPEG Images do not get rotated correctly
By: mirek on Wed, 31 October 2018 11:12
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Wed, 31 October 2018 19:30
|
|
|
Re: JPEG Images do not get rotated correctly
By: mirek on Thu, 01 November 2018 08:34
|
|
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 01 November 2018 09:57
|
Goto Forum:
Current Time: Mon May 06 11:56:10 CEST 2024
Total time taken to generate the page: 0.02206 seconds
|