kl teh

kl teh

  • NA
  • 3
  • 0

some error

Mar 16 2009 11:43 AM
error that occur:
the name "convertToInt32U" does not exist in the current context

basically i am adding a lil code into the existing program,i am beginner to this c# language so do correct/guide me please (do tell me if u want the source code,i can email them to u)


[quote]

using System;

using System.Collections.Generic;

using System.Drawing.Imaging;

using System.Text;

using System.Windows.Media.Imaging;

 

namespace WPFExifInfo

{

    public class ExifMetaInfo

    {

        private BitmapMetadata _metaInfo;

 

        public ExifMetaInfo(Uri imageUri)

        {

            BitmapFrame bFrame = BitmapFrame.Create(imageUri, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);

            _metaInfo = (BitmapMetadata)bFrame.Metadata;

        }

 

        private void buildDB(System.Drawing.Imaging.PropertyItem[] parr)

        {

            properties.Clear();

            //

            data = "";

            //

            Encoding ascii = Encoding.ASCII;

            //

            foreach (System.Drawing.Imaging.PropertyItem p in parr)

            {

                string v = "";

                string name = (string)myHash[p.Id];

                // tag not found. skip it

                if (name == null) continue;

                //

                data += name + ": ";

                //My code starts here

                if (p.Id == 0x0004)

                {

                    //lat

                    // rational

                    byte[] deg = new byte[4];

                    byte[] degdiv = new byte[4];

                    byte[] min = new byte[4];

                    byte[] mindiv = new byte[4];

                    byte[] sec = new byte[4];

                    byte[] secdiv = new byte[4];

                    Array.Copy(p.Value, 0, deg, 0, 4);

                    Array.Copy(p.Value, 4, degdiv, 0, 4);

                    Array.Copy(p.Value, 8, min, 0, 4);

                    Array.Copy(p.Value, 12, mindiv, 0, 4);

                    Array.Copy(p.Value, 16, sec, 0, 4);

                    Array.Copy(p.Value, 20, secdiv, 0, 4);

                    double a = convertToInt32U(deg);

                    double b = convertToInt32U(degdiv);

                    double c = convertToInt32U(min);

                    double d = convertToInt32U(mindiv);

                    double e = convertToInt32U(sec);

                    double f = convertToInt32U(secdiv);

                    double o = ((a / b) + ((c / b) / 60) + ((e / f) / 3600));

                    v = o.ToString();

                    // Rational r = new Rational(a, b);

                }

                else if (p.Id == 0x0002)

                {

                    //long

                    byte[] deg = new byte[4];

                    byte[] degdiv = new byte[4];

                    byte[] min = new byte[4];

                    byte[] mindiv = new byte[4];

                    byte[] sec = new byte[4];

                    byte[] secdiv = new byte[4];

                    Array.Copy(p.Value, 0, deg, 0, 4);

                    Array.Copy(p.Value, 4, degdiv, 0, 4);

                    Array.Copy(p.Value, 8, min, 0, 4);

                    Array.Copy(p.Value, 12, mindiv, 0, 4);

                    Array.Copy(p.Value, 16, sec, 0, 4);

                    Array.Copy(p.Value, 20, secdiv, 0, 4);

                    double a = convertToInt32U(deg);

                    double b = convertToInt32U(degdiv);

                    double c = convertToInt32U(min);

                    double d = convertToInt32U(mindiv);

                    double e = convertToInt32U(sec);

                    double f = convertToInt32U(secdiv);

                    double o = ((a / b) + ((c / b) / 60) + ((e / f) / 3600));

                    v = o.ToString();

                }

            }

        }

                    //My Code ends here

 

        /*

         

        private object GetMetaInfo(string infoQuery)

        {

            if (_metaInfo.ContainsQuery(infoQuery))

                return _metaInfo.GetQuery(infoQuery);

            else

                return null;

        }

 

        public uint? Width

        {

            get

            {

                object obj = GetMetaInfo("/app1/ifd/exif/subifd:{uint=40962}");

                if (obj == null)

                {

                    return null;

                }

                else

                {

                    if (obj.GetType() == typeof(UInt32))

                        return (uint)obj;

                    else

                        return Convert.ToUInt32(obj);

                }

            }

        }

        public uint? Height

        {

            get

            {

                object obj = GetMetaInfo("/app1/ifd/exif/subifd:{uint=40963}");

                if (obj == null)

                {

                    return null;

                }

                else

                {

                    if (obj.GetType() == typeof(UInt32))

                        return (uint)obj;

                    else

                        return Convert.ToUInt32(obj);

                }

            }

        }

        public string EquipmentManufacturer

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif:{uint=271}");

                return (val != null ? (string)val : String.Empty);

            }

        }

 

        public string CameraModel

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif:{uint=272}");

                return (val != null ? (string)val : String.Empty);

            }

        }

 

        public string CreationSoftware

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif:{uint=305}");

                return (val != null ? (string)val : String.Empty);

            }

        }

 

        public ColorRepresentation ColorRepresentation

        {

            get

            {

                if ((ushort)GetMetaInfo("/app1/ifd/exif/subifd:{uint=40961}") == 1)

                    return ColorRepresentation.sRGB;

                else

                    return ColorRepresentation.Uncalibrated;

            }

        }

 

        public decimal? ExposureTime

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif/subifd:{uint=33434}");

                if (val != null)

                {

                    return ParseUnsigned((ulong)val);

                }

                else

                {

                    return null;

                }

            }

        }

 

 

        public decimal? LensAperture

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif/subifd:{uint=33437}");

                if (val != null)

                {

                    return ParseUnsigned((ulong)val);

                }

                else

                {

                    return null;

                }

            }

        }

 

        public decimal? FocalLength

        {

            get

            {

                object val = GetMetaInfo("/app1/ifd/exif/subifd:{uint=37386}");

                if (val != null)

                {

                    return ParseUnsigned((ulong)val);

                }

                else

                {

                    return null;

                }

            }

        }

 

        public ushort? IsoSpeed

        {

            get

            {

                return (ushort?)GetMetaInfo("/app1/ifd/exif/subifd:{uint=34855}");

            }

        }

 

        public FlashMode FlashMode

        {

            get

            {

                if ((ushort)GetMetaInfo("/app1/ifd/exif/subifd:{uint=37385}") % 2 == 1)

                    return FlashMode.FlashFired;

                else

                    return FlashMode.FlashNotFire;

            }

        }

 

        private decimal ParseUnsigned(ulong exifValue)

        {

            return (decimal)(exifValue & 0xFFFFFFFFL) / (decimal)((exifValue & 0xFFFFFFFF00000000L) >> 32);

        }

    }

    public enum ColorRepresentation

    {

        sRGB,

        Uncalibrated

    }

    public enum FlashMode

    {

        FlashFired,

        FlashNotFire

    }

 

           

                   

 

}

 [/quote]


Answers (2)