Sunday, April 26, 2015

How to Convert BitmapImage to Storage File in Windows Phone 8.1 Win RT

BitmapImage to Storage File conversion requires following steps.
  1. BitmapImage to byte array conversion.
  2. Creation of temporary StorageFile.
  3. Writing byte array data on empty storage file.
BitmapImage to byte array conversion

BitmapImage bitmap = ImageBoxPreview.Source as BitmapImage;

RandomAccessStreamReference rasr = RandomAccessStreamReference.CreateFromUri(bitmap.UriSource);

var streamWithContent = await rasr.OpenReadAsync();

byte[] buffer = new byte[streamWithContent.Size];

await streamWithContent.ReadAsync(buffer.AsBuffer(),(uint)streamWithContent.Size, InputStreamOptions.None);


Creation of temporary StorageFile

StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("temp.jpeg", CreationCollisionOption.ReplaceExisting);


Writing byte array data on empty storage file

using (IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
      using (IOutputStream outputStream = fileStream.GetOutputStreamAt(0))
      {
               using (DataWriter dataWriter = new DataWriter(outputStream))
               {
                      dataWriter.WriteBytes(buffer);
                      await dataWriter.StoreAsync(); // 
                      dataWriter.DetachStream();
               }
               // write data on the empty file:
               outputStream.FlushAsync();
       }
        fileStream.FlushAsync();
}



Complete code will be:


Convert BitmapImage  to Storage File in Windows Phone 8.1 Win RT

Convert BitmapImage to Storage File in Windows Phone 8.1 Win RT.

Monday, November 10, 2014

ORA-00299 Must use file level media recovery on data file string

Error Code
ORA-00299

Description
Must use file-level media recovery on data file string.

Cause
Possible cause of this error is, the control file does not contain an entry for this file, so block media recovery cannot be done.

Action
To fix this issue, restore the data file and perform file-level media recovery.

reference

ORA-00298 Missing or invalid attribute value

Error Code
ORA-00298

Description
Missing or invalid attribute value.

Cause
Possible cause of this error is, a non-zero integer value is required when the following keyword attributes are specified: TIMEOUT, EXPIRE, DELAY, NEXT

Action
To fix this issue, correct the syntax and retry the command.

reference

ORA-00297 Must specify RECOVER DATAFILE LIST before RECOVER DATAFILE START

Error Code
ORA-00297

Description
Must specify RECOVER DATAFILE LIST before RECOVER DATAFILE START.

Cause
Possible cause of this error is, the RECOVER DATAFILE START command was issued, but no RECOVER DATAFILE LIST commands had been issued. This only happens when doing recovery with Recovery Manager, and is an internal error in Recovery Manager, because Recovery Manager should always issue RECOVER DATAFILE LIST before RECOVER DATAFILE START.

Action
To fix this issue, contact customer support

reference

ORA-00296 Maximum number of files exceeded for RECOVER DATAFILE LIST

Error Code
ORA-00296

Description
Maximum number of files (string) exceeded for RECOVER DATAFILE LIST.

Cause
Possible cause of this error is, the RECOVER DATAFILE LIST command specified more datafiles than are allowed by the DB_FILES initialization parameter. This error occurs when doing recovery with Recovery Manager, and the instance has been started with a DB_FILES parameter specifying fewer datafiles than recovery manager needs to recover to satisfy the user's RECOVER command.

Action
To fix this issue, re-start the instance with a higher value for DB_FILES.

reference