Example #1
0
            public static async Task SecretData(StorageFile file)
            {
                IRandomAccessStream ram;

                using (ram = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    GetData.Decoder = await BitmapDecoder.CreateAsync(ram);

                    BitmapPropertySet prop = await GetData.Decoder.BitmapProperties.GetPropertiesAsync(new string[] { Data.Misc.Secret });

                    if (prop.ContainsKey(Data.Misc.Secret) == true)
                    {
                        GetData.Reset_Data("Extract", "Secret");
                        string[] secret = ((string)prop[Data.Misc.Secret].Value).Split('|');

                        GetData.SecretData.Add(Data.Misc.DataPassword, secret[0]);
                        GetData.SecretData.Add(Data.Misc.DataType, secret[1]);
                        GetData.SecretData.Add(Data.Misc.DataNameFile, secret[2]);
                        GetData.SecretData.Add(Data.Misc.DataExtension, secret[3]);
                        GetData.SecretData.Add(Data.Misc.DataSecret, secret[4]);
                    }
                    else
                    {
                        GetData.Reset_Data("Extract", "Secret");
                    }
                }
            }
Example #2
0
        /// <summary>
        /// Asynchronously attempts to get the oriented dimensions and EXIF orientation from the image file.
        /// Sets member variables instead of returning a value with the Task.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task GetImageInformationAsync(StorageFile file)
        {
            using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read))
            {
                BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

                // The orientedPixelWidth and Height members provide the image dimensions
                // reflecting any EXIF orientation.
                m_displayHeightNonScaled = decoder.OrientedPixelHeight;
                m_displayWidthNonScaled  = decoder.OrientedPixelWidth;

                try
                {
                    // Property access using BitmapProperties is similar to using
                    // Windows.Storage.FileProperties (see Scenario 1); BitmapProperties accepts
                    // property keys such as "System.Photo.Orientation".
                    // The EXIF orientation flag can be also be read using native metadata queries
                    // such as "/app1/ifd/{ushort=274}" (JPEG) or "/ifd/{ushort=274}" (TIFF).
                    string[]          requestedProperties = { "System.Photo.Orientation" };
                    BitmapPropertySet retrievedProperties =
                        await decoder.BitmapProperties.GetPropertiesAsync(requestedProperties);

                    // Check to see if the property exists in the file.
                    if (retrievedProperties.ContainsKey("System.Photo.Orientation"))
                    {
                        // EXIF orientation ("System.Photo.Orientation") is stored as a 16-bit unsigned integer.
                        m_exifOrientation = Helpers.ConvertToPhotoOrientation(
                            (ushort)retrievedProperties["System.Photo.Orientation"].Value
                            );
                    }
                }
                catch (Exception err)
                {
                    switch (err.HResult)
                    {
                    // If the file format does not support properties continue without applying EXIF orientation.
                    case WINCODEC_ERR_UNSUPPORTEDOPERATION:
                    case WINCODEC_ERR_PROPERTYNOTSUPPORTED:
                        m_disableExifOrientation = true;
                        break;

                    default:
                        throw err;
                    }
                }
            }
        }