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 #50409 is a reply to message #50393] Sun, 21 October 2018 16:20 Go to previous messageGo to previous message
Tom1
Messages: 1303
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Could you possibly add two lines of code in jpgupp.cpp in order to support Exif "DateTime" -tag:
int JPGRaster::Data::ExifDir(const char *begin, int offset, IFD_TYPE type)
{
	const char *e = begin + offset;
	int nitems = Exif16(e);
//	puts(NFormat("directory %08x: %d items", dir, nitems));
	e += 2;
	for(int i = 0; i < nitems; i++, e += 12) {
		int tag = Exif16(e);
		int fmt = Exif16(e + 2);
		int count = Exif32(e + 4);
		static const int fmtlen[] = {
			1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8
		};
		int len = 0;
		if(fmt > 0 && fmt <= __countof(fmtlen))
			len = fmtlen[fmt - 1] * count;
		const char *data = e + 8;
		if(len > 4)
			data = begin + Exif32(data);
//		puts(NFormat("[%d]: tag %04x fmt %d, count %d, data %s",
//			i, tag, fmt, count, BinHexEncode(data, data + len)));
		if(type == BASE_IFD) {
			if(tag == 0x112)
				metadata.Add("orientation", Exif16(data));
			if(tag == 0x132)
				metadata.Add("DateTime", String(data, 20));
			if(tag == 0x8825) {
				int offset = Exif32(data);
	//			puts(NFormat("GPS IFD at %08x", offset));
				ExifDir(begin, offset, GPS_IFD);
			}
		}
		else if(type == GPS_IFD) {
			if((tag == 2 || tag == 4) && fmt == EXIF_RATIONAL && count == 3) {
				metadata.Add(tag == 2 ? "GPSLatitude" : "GPSLongitude",
					ExifF5(data + 0) + ExifF5(data + 8) / 60 + ExifF5(data + 16) / 3600);
//				puts(NFormat("GPSLatitude: %n %n %n", n1, n2, n3));
			}
			else if(tag == 6 && fmt == EXIF_RATIONAL && count == 1)
				metadata.Add("GPSAltitude", ExifF5(data));
			else if(tag == 16 && fmt == EXIF_ASCII && count == 2 && *data)
				metadata.Add("GPSImgDirectionRef", String(*data, 1));
			else if(tag == 17 && fmt == EXIF_RATIONAL && count == 1)
				metadata.Add("GPSImgDirection", ExifF5(data + 0));
		}
	}
	int nextoff = Exif32(e);
//	puts(NFormat("next offset = %08x", nextoff));
	return nextoff;
}


More specifically those reading:
			if(tag == 0x132)
				metadata.Add("DateTime", String(data, 20));


This would be great help!

Best regards,

Tom
 
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: Wed Jun 25 05:11:11 CEST 2025

Total time taken to generate the page: 0.04125 seconds