Académique Documents
Professionnel Documents
Culture Documents
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
namespace PROG
{
public class Fotografia
{
public Image image;
public Dictionary<PropertyTagId,
KeyValuePair<PropertyTagType, Object>> imageProps =
new Dictionary<PropertyTagId,KeyValuePair<PropertyTagType,object>>()
;
public string refLatitud; // S-N
public string refLongitud; // W-E
public
public
public
public
public
bool tieneCoordGeo;
double latitud;
double longitud;
double elevacion;
string datum;
string
string
string
string
name;
rename;
categoria;
prefijo;
//
//
//
//
switch ((PropertyTagType)property.Type)
{
case PropertyTagType.Byte:
propValue = ((byte[])property.Value)[0];
break;
case PropertyTagType.ASCII:
ASCIIEncoding encoding = new ASCIIEncoding();
propValue = encoding.GetString(
property.Value, 0, property.Len - 1);
if(property.Id==1) refLatitud = (string) propValue;
if(property.Id==3) refLongitud = (string) propValue;
if(property.Id==18) datum = (string) propValue;
break;
case PropertyTagType.Int16:
propValue = BitConverter.ToInt16(
property.Value, 0);
break;
case PropertyTagType.SLONG:
case PropertyTagType.Int32:
propValue = BitConverter.ToInt32(
property.Value, 0);
break;
case PropertyTagType.SRational:
case PropertyTagType.Rational:
if(property.Id==2 || property.Id==4) // grado,minuto,seg
undo
{
double g = BitConverter.ToUInt32(property.Value,
0);
double m = BitConverter.ToUInt32(property.Value,
8);
double s = dividir(BitConverter.ToUInt32(propert
y.Value, 16),
BitConverter.ToUInt32(property.Va
lue, 20));
double a = g+m/60+s/3600;
propValue = g+"; "+m+"; "+s;
if(property.Id==2)
{
latitud = a;
if(refLatitud=="S") latitud *= -1;
}
if(property.Id==4)
{
longitud = a;
if(refLongitud=="W") longitud *= -1;
tieneCoordGeo = true;
}
}
else
{
propValue = dividir(BitConverter.ToUInt32(proper
ty.Value,0),
BitConverter.ToUInt32(proper
ty.Value,4));
if(property.Id==6) elevacion = (double) propValu
e;
}
break;
case PropertyTagType.Undefined:
propValue = "Undefined Data";
break;
}
imageProps.Add(NumToEnum<PropertyTagId>(property.Id),
new KeyValuePair<PropertyTagType,object>(
NumToEnum<PropertyTagType>(property.Type),
propValue));
}
if(tieneCoordGeo)
{
object[] utm = WGS84.LatLonToUTM(latitud,longitud);
zonaBanda = utm[0]+""+utm[1];
este = (double) utm[2];
norte = (double) utm[3];
}
}
public double dividir(uint n1, uint n2)
{
if(n2!=0) return (double)n1 / (double)n2;
else return 0;
}
public T NumToEnum<T>(int number)
{
return (T)Enum.ToObject(typeof(T), number);
}
}
}