PC Review


Reply
Thread Tools Rate Thread

Adopt Metadata at converting an image

 
 
Johann Löwen
Guest
Posts: n/a
 
      5th Oct 2009
If I trying to convert a RAW-Image (CR2) to a WDP (HDP)-Image so i loose the
Metadata!

How can i fix it?

Public Sub SaveAsHdp(ByVal sourceStream As System.IO.Stream, ByVal
destinationStream As System.IO.Stream, ByVal quality As Int32)
If ((sourceStream IsNot Nothing) AndAlso (sourceStream.CanRead))
And ((destinationStream IsNot Nothing) AndAlso (destinationStream.CanWrite))
Then
Dim decoder As System.Windows.Media.Imaging.BitmapDecoder =
Nothing

Try
decoder =
System.Windows.Media.Imaging.BitmapDecoder.Create(sourceStream,
Windows.Media.Imaging.BitmapCreateOptions.PreservePixelFormat Or
Windows.Media.Imaging.BitmapCreateOptions.IgnoreColorProfile,
System.Windows.Media.Imaging.BitmapCacheOption.Default)

If (decoder.Frames.Count > 0) AndAlso (decoder.Frames(0)
IsNot Nothing) Then
Dim destinationFrame As
Windows.Media.Imaging.BitmapFrame = Nothing
Dim imageEncoder As New
System.Windows.Media.Imaging.WmpBitmapEncoder()

Try
destinationFrame =
Windows.Media.Imaging.BitmapFrame.Create(decoder.Frames(0),
decoder.Frames(0).Thumbnail, decoder.Frames(0).Metadata.Clone(),
decoder.ColorContexts)

If quality <= 0 Then quality = 1
If quality > 100 Then quality = 100
imageEncoder.ImageQualityLevel = quality / 100
imageEncoder.Frames.Add(destinationFrame)
imageEncoder.Save(destinationStream)

destinationStream.Flush()
Catch ex As Exception
Throw
Finally
destinationFrame = Nothing
imageEncoder = Nothing
End Try
End If
Catch ex As Exception
Throw New System.IO.FileFormatException("FileFormat not
supported")
Finally
decoder = Nothing
End Try
Else
Throw New System.ArgumentOutOfRangeException("Can't handle
Stream-Argument!")
End If
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image Metadata Roger Microsoft C# .NET 1 26th May 2008 10:55 PM
Overwriting image metadata Tim Kelley Microsoft C# .NET 2 20th May 2008 05:07 PM
Extracting Image Metadata BluDog Microsoft VB .NET 2 27th May 2004 04:52 PM
Extracting Image Metadata BluDog Microsoft VB .NET 0 27th May 2004 11:47 AM
http://adopt.hotbar.com/adopt.jsp? buttasylum Windows XP Internet Explorer 2 17th Aug 2003 11:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:07 AM.