Click here to Skip to main content
15,891,657 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to got the programming is compiled by x64 or x86 Pin
Dracula Wang8-Apr-09 19:44
Dracula Wang8-Apr-09 19:44 
AnswerRe: how to got the programming is compiled by x64 or x86 Pin
Anubhava Dimri8-Apr-09 18:58
Anubhava Dimri8-Apr-09 18:58 
GeneralRe: how to got the programming is compiled by x64 or x86 Pin
Dracula Wang8-Apr-09 19:43
Dracula Wang8-Apr-09 19:43 
QuestionWhat Happens If I Don't Close A Text File Pin
BlitzPackage8-Apr-09 16:26
BlitzPackage8-Apr-09 16:26 
AnswerRe: What Happens If I Don't Close A Text File Pin
Luc Pattyn8-Apr-09 16:42
sitebuilderLuc Pattyn8-Apr-09 16:42 
GeneralRe: What Happens If I Don't Close A Text File Pin
BlitzPackage8-Apr-09 16:50
BlitzPackage8-Apr-09 16:50 
QuestionRead Photo Taken Date Pin
S K Y8-Apr-09 15:02
S K Y8-Apr-09 15:02 
AnswerRe: Read Photo Taken Date Pin
Luc Pattyn8-Apr-09 15:14
sitebuilderLuc Pattyn8-Apr-09 15:14 
Some file formats (including JPEG) allow for a lot of metadata, and most camera's seem to provide at least some of these pieces of information.

Here is some code that may be useful to you; I will not provide support on it though.

	string s=readImageProperty(image, 0x132);	// ASCII
	log("datetime="+s);
	DateTime exposureDate=ParseExposureDate(s, equipModel);
	log("Exposure DateTime = "+DateToString(exposureDate, false, ""));


// reads a specific property from an image, and returns it as a string
// (whatever format it originally had);
// returns null when property is not available.
// typically only works if image got loaded from a JPEG file.
private static string readImageProperty(Image image, int ID) {
	try {
		PropertyItem pi=image.GetPropertyItem(ID);	// DateTime
		if(pi!=null) {
			if(pi.Type==2) {	// ASCII
				return ASCIIencoding.GetString(pi.Value, 0, pi.Len-1);
			}
			if(pi.Type==5) {	// rational
				byte[] bb=pi.Value;
				uint uNominator=BitConverter.ToUInt32(bb, 0);
				uint uDenominator=BitConverter.ToUInt32(bb, 4);
				if(uDenominator==1) return uNominator.ToString();
				return uNominator.ToString()+"/"+uDenominator.ToString();
			}
		}
	} catch {	// catch and ignore all kinds of exceptions, such as "no such property"
	}
	return null;
}

// Converts a JPEG datetime property to a standard DateTime;
// may try several known formats, and returns DateTime.MinValue on failure.
// REMARK: if necessary, make the format candidates depend on
//		   (part of) the equipment model
private static DateTime ParseExposureDate(string exposure, string equipModel) {
	DateTime dt=DateTime.MinValue;
	bool OK=false;
	// repeat the next IF block, with different arguments, for each
	// possible DateTime format (or each camera)
	if(!OK) {
		// NIKON D70s gives:			"2007:04:07 09:02:00"
		// Canon PowerShot A620 gives:	"2006:09:25 18:43:33"
		// Olympus C460 gives:			"2006:03:12 15:49:54"
		// Olympus FE200 gives:			"2007:03:17 01:18:30"
		OK=DateTime.TryParseExact(exposure, "yyyy:MM:dd HH:mm:ss",
			null, DateTimeStyles.None, out dt);
	}
	log("ParseExposureDate: \""+exposure+"\" >>> "+dt);
	return dt;
}


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


General[Message Deleted] Pin
S K Y8-Apr-09 15:41
S K Y8-Apr-09 15:41 
GeneralRe: Read Photo Taken Date Pin
Luc Pattyn8-Apr-09 16:04
sitebuilderLuc Pattyn8-Apr-09 16:04 
QuestionSystem.Data.OracleClient - "System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." [modified] Pin
devvvy8-Apr-09 14:58
devvvy8-Apr-09 14:58 
QuestionLarge memory usage. Pin
Jacob Dixon8-Apr-09 14:55
Jacob Dixon8-Apr-09 14:55 
AnswerRe: Large memory usage. Pin
Jacob Dixon8-Apr-09 15:00
Jacob Dixon8-Apr-09 15:00 
AnswerRe: Large memory usage. Pin
Luc Pattyn8-Apr-09 15:04
sitebuilderLuc Pattyn8-Apr-09 15:04 
GeneralRe: Large memory usage. Pin
Jacob Dixon8-Apr-09 15:10
Jacob Dixon8-Apr-09 15:10 
GeneralRe: Large memory usage. Pin
Luc Pattyn8-Apr-09 15:15
sitebuilderLuc Pattyn8-Apr-09 15:15 
GeneralRe: Large memory usage. Pin
Jacob Dixon8-Apr-09 16:52
Jacob Dixon8-Apr-09 16:52 
GeneralRe: Large memory usage. Pin
Luc Pattyn8-Apr-09 17:17
sitebuilderLuc Pattyn8-Apr-09 17:17 
GeneralRe: Large memory usage. Pin
harold aptroot8-Apr-09 15:35
harold aptroot8-Apr-09 15:35 
GeneralRe: Large memory usage. Pin
Luc Pattyn8-Apr-09 15:58
sitebuilderLuc Pattyn8-Apr-09 15:58 
GeneralRe: Large memory usage. Pin
harold aptroot8-Apr-09 16:37
harold aptroot8-Apr-09 16:37 
GeneralRe: Large memory usage. Pin
Luc Pattyn8-Apr-09 17:05
sitebuilderLuc Pattyn8-Apr-09 17:05 
GeneralRe: Large memory usage. Pin
Dave Kreskowiak8-Apr-09 17:47
mveDave Kreskowiak8-Apr-09 17:47 
GeneralRe: Large memory usage. Pin
harold aptroot9-Apr-09 4:59
harold aptroot9-Apr-09 4:59 
GeneralRe: Large memory usage. Pin
Dave Kreskowiak9-Apr-09 13:16
mveDave Kreskowiak9-Apr-09 13:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.