Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  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


[Updated on: Thu, 04 October 2018 12:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DrawArc not working in GTK mode
Next Topic: RescaleFilter.cpp: Implicit conversion from bool to double
Goto Forum:
  


Current Time: Mon May 06 11:56:10 CEST 2024

Total time taken to generate the page: 0.02206 seconds