Click here to Skip to main content
16,005,141 members
Home / Discussions / C#
   

C#

 
GeneralRe: I want to load a button in the title bar Pin
flydk11-Aug-09 14:41
flydk11-Aug-09 14:41 
GeneralRe: I want to load a button in the title bar Pin
Saksida Bojan12-Aug-09 8:19
Saksida Bojan12-Aug-09 8:19 
GeneralRe: I want to load a button in the title bar Pin
flydk12-Aug-09 19:09
flydk12-Aug-09 19:09 
QuestionReplace(@"\\", @"\") not working Pin
dptalt11-Aug-09 3:22
dptalt11-Aug-09 3:22 
AnswerRe: Replace(@"\\", @"\") not working Pin
Andrew Rissing11-Aug-09 3:58
Andrew Rissing11-Aug-09 3:58 
GeneralRe: Replace(@"\\", @"\") not working Pin
dptalt11-Aug-09 4:04
dptalt11-Aug-09 4:04 
Questionhow to get data from the tags of a TIFF image Pin
gilvani11-Aug-09 3:05
gilvani11-Aug-09 3:05 
AnswerRe: how to get data from the tags of a TIFF image Pin
Luc Pattyn11-Aug-09 3:21
sitebuilderLuc Pattyn11-Aug-09 3:21 
Hi,

here is some code I've been using for that purpose, it was aiming at JPEG though:

	FileStream stream=new FileStream(fileSpec, FileMode.Open, FileAccess.Read);
	//File.OpenRead(fileSpec);
	Image localImage2=Image.FromStream(stream);
#if true
	int[] piList=localImage2.PropertyIdList;
	Dictionary<int, string> propNames=new Dictionary<int,string>();
	propNames.Add(0x010E, "ImageDescription");
	propNames.Add(0x010F, "EquipMake");
	propNames.Add(0x0110, "EquipModel");
	propNames.Add(0x0112, "Orientation");
	propNames.Add(0x011A, "XResolution");
	propNames.Add(0x011B, "YResolution");
	propNames.Add(0x0132, "DateTime");
	propNames.Add(0x0128, "ResolutionUnit");
	propNames.Add(0x0131, "SoftwareUsed");
	propNames.Add(0x0201, "JPEGInterFormat");
	propNames.Add(0x0202, "JPEGInterLength");
	propNames.Add(0x0213, "YCbCrPositioning");
	propNames.Add(0x501B, "ThumbnailData");
	propNames.Add(0x502D, "ThumbnailResolutionX");
	propNames.Add(0x502E, "ThumbnailResolutionY");
	propNames.Add(0x5090, "LuminanceTable");
	propNames.Add(0x5091, "ChrominanceTable");
	propNames.Add(0x829A, "ExifExposureTime");
	propNames.Add(0x9003, "ExifDTOrig");
	propNames.Add(0x9004, "ExifDTDigitized");
	propNames.Add(0x9204, "ExifExposureBias");
	propNames.Add(0x9209, "ExifFlash");
	propNames.Add(0x927C, "ExifMakerNote");
	propNames.Add(0x9286, "ExifUserComment");
	propNames.Add(0xA002, "ExifPixXDim");
	propNames.Add(0xA003, "ExifPixYDim");
	foreach (int ID in piList) {
		//if (propNames[ID]==null) getPropertyItem(localImage2, ID, propNames);
		if (propNames.ContainsKey(ID)) getPropertyItem(localImage2, ID, propNames);
	}
#endif
	// we now create a copy, so we can close the filestream
	// MSDN says: You must keep the stream open for the lifetime of the Image object.
	// see also the article "PRB: Image File Is Locked When You Set the PictureBox
	// Image Property to a File"
	localImage=new Bitmap(localImage2);
	stream.Close();
	localImage2.Dispose();


and
protected void getPropertyItem(Image image, int ID, Dictionary<int, string> propNames) {
	string s=(string)propNames[ID];
	if (s==null) s="";
	s+=new string(' ', 20);
	s=s.Substring(0, 20);
	string name="Prop"+LP_Format.Hex4(ID)+" "+s;
	string type=null;
	try {
		PropertyItem pi=image.GetPropertyItem(ID);
		s="";
		byte[] bb=pi.Value;
		switch ((PropertyTagType)pi.Type) {
			case PropertyTagType.Byte: 
				type="(byte)";
				for (int i=0; i<bb.Length; i++) {
					byte us=bb[i];
					s+=" "+us.ToString("X2");
					if (bb.Length==1) s+="("+us.ToString()+")";
				}
				break;
			case PropertyTagType.ASCII:
				type="(ASCII)";
				s=" "+ASCIIencoding.GetString(pi.Value, 0, pi.Len-1);
				break;
			case PropertyTagType.Short:
				type="(short)";
				for (int i=0; i<bb.Length/2; i++) {
					ushort us=BitConverter.ToUInt16(bb,2*i);
					s+=" "+us.ToString("X4");
					if (bb.Length==2) s+="("+us.ToString()+")";
				}
				break;
			case PropertyTagType.Long :
				type="(long)";
				for (int i=0; i<bb.Length/4; i++) {
					ulong us=BitConverter.ToUInt32(bb,4*i);
					s+=" "+us.ToString("X8");
					if (bb.Length==4) s+="("+us.ToString()+")";
				}
				break;
			case PropertyTagType.Rational:
				type="(rational)";
				for (int i=0; i<bb.Length/8; i++) {
					uint uNominator=BitConverter.ToUInt32(bb, 8*i);
					uint uDenominator=BitConverter.ToUInt32(bb, 8*i+4);
					s+=" "+uNominator.ToString()+"/"+uDenominator.ToString();
				}
				break;
			case PropertyTagType.Undefined:
				type="(undefined)";
				for(int i=0; i<bb.Length; i++) {
					s+=" "+bb[i].ToString("X2");
				}
				break;
			case PropertyTagType.SRational:
				type="(srational)";
				for (int i=0; i<bb.Length/8; i++) {
					int uNominator=BitConverter.ToInt32(bb, 8*i);
					int uDenominator=BitConverter.ToInt32(bb, 8*i+4);
					s+=" "+uNominator.ToString()+"/"+uDenominator.ToString();
				}
				break;
		}
		if (type==null) type="?"+pi.Type+"?";
		env.log(0, name+LP_String.Extend(type, 12)+s);
	} catch (Exception exc) {
		env.log(0, "Unable to obtain "+name+"; "+exc.Message);
	}
}


Hope this helps.

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

QuestionHow to apply RowFilter for a String Date Pin
Sreedhar Kadiyala11-Aug-09 3:02
Sreedhar Kadiyala11-Aug-09 3:02 
AnswerRe: How to apply RowFilter for a String Date Pin
dptalt11-Aug-09 3:49
dptalt11-Aug-09 3:49 
AnswerRe: How to apply RowFilter for a String Date Pin
Anjups7-Sep-09 20:40
Anjups7-Sep-09 20:40 
QuestionDateTime.TryParseExact() problem? Pin
Henk Meijerink11-Aug-09 2:46
Henk Meijerink11-Aug-09 2:46 
AnswerRe: DateTime.TryParseExact() problem? Pin
stancrm11-Aug-09 2:57
stancrm11-Aug-09 2:57 
GeneralRe: DateTime.TryParseExact() problem? Pin
Henk Meijerink11-Aug-09 3:45
Henk Meijerink11-Aug-09 3:45 
QuestionUpdated:Filter for DataGridView [modified] Pin
janadhana11-Aug-09 2:14
janadhana11-Aug-09 2:14 
AnswerRe: Updated:Filter for DataGridView Pin
Sreedhar Kadiyala11-Aug-09 2:49
Sreedhar Kadiyala11-Aug-09 2:49 
GeneralRe: Updated:Filter for DataGridView Pin
janadhana11-Aug-09 19:36
janadhana11-Aug-09 19:36 
AnswerRe: Updated:Filter for DataGridView Pin
dan!sh 11-Aug-09 2:58
professional dan!sh 11-Aug-09 2:58 
GeneralRe: Updated:Filter for DataGridView Pin
janadhana11-Aug-09 19:37
janadhana11-Aug-09 19:37 
AnswerRe: Updated:Filter for DataGridView Pin
Henry Minute11-Aug-09 5:00
Henry Minute11-Aug-09 5:00 
GeneralRe: Updated:Filter for DataGridView Pin
janadhana11-Aug-09 19:39
janadhana11-Aug-09 19:39 
Questionq in datagirdview Pin
mohammad alnoed11-Aug-09 1:15
mohammad alnoed11-Aug-09 1:15 
AnswerRe: q in datagirdview Pin
padmanabhan N11-Aug-09 1:35
padmanabhan N11-Aug-09 1:35 
AnswerRe: q in datagirdview Pin
Arindam Sinha11-Aug-09 1:39
Arindam Sinha11-Aug-09 1:39 
AnswerRe: q in datagirdview Pin
Henry Minute11-Aug-09 2:12
Henry Minute11-Aug-09 2:12 

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.