Click here to Skip to main content
15,884,628 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: UserControl question Pin
RugbyLeague1-May-09 9:19
RugbyLeague1-May-09 9:19 
GeneralRe: UserControl question Pin
Gideon Engelberth1-May-09 17:09
Gideon Engelberth1-May-09 17:09 
AnswerRe: UserControl question Pin
fjparisIII3-May-09 2:22
fjparisIII3-May-09 2:22 
QuestionMy WCF client deadlock Pin
Richard Dutton1-May-09 4:32
Richard Dutton1-May-09 4:32 
QuestionDependency properties!Performance issue Pin
pioner30-Apr-09 19:48
pioner30-Apr-09 19:48 
AnswerRe: Dependency properties!Performance issue Pin
Gideon Engelberth1-May-09 3:27
Gideon Engelberth1-May-09 3:27 
QuestionSaving image transform without losing metadata Pin
fjparisIII30-Apr-09 6:35
fjparisIII30-Apr-09 6:35 
AnswerRe: Saving image transform without losing metadata Pin
fjparisIII30-Apr-09 8:47
fjparisIII30-Apr-09 8:47 
I thought I finally came up with the solution very elegantly, but was shocked to find out that what seemed like the obvious answer simply does not work. As I mentioned, I am correctly capturing the metadata from the original image. Then in doggedly perusing the MSDN documentation, I slapped myself aside the head when I noticed an additional signature to BitmapFrame.Create() that seemed to supply the answer. Originally I was using this signature:

public static BitmapFrame Create(BitmapSource source)


After looking over the additional signatures for Create, I noticed this one:

public static BitmapFrame Create(
	BitmapSource source,
	BitmapSource thumbnail,
	BitmapMetadata metadata,
	ReadOnlyCollection<ColorContext> colorContexts
)


Eureka! I thought. But after enhancing my call to the latter, the destination files still have no metadata, as if the metadata parameter is just being ignored.

I am just stunned. The source parameter isn't being ignored: the original image is correctly scaled in the new file. At least I'm not getting an exception anymore, but now I am more baffled than ever. Here is my code, expanded more than is needed if the code worked, but parameters exposed so I could trace into the code to see if anything looked wrong (destinationPath and metadata are input parameters to the function):

WmpBitmapEncoder encoderWmp = new WmpBitmapEncoder();
FileStream stream = new FileStream(destinationPath, FileMode.Create);
BitmapMetadata bm = (BitmapMetadata)metadata;
encoderWmp.Frames.Add(BitmapFrame.Create(scaledBitmap, null, bm, null));
BitmapFrame bf = encoderWmp.Frames[0];
encoderWmp.Save(stream);


I wanted to see if bf still contained my original bitmap metadata. Tracing into the code indicates that it does! How could anything be set up more perfectly? Yet the metadata does not get into the image when the Save in the last statement is executed.

What seemed like an obvious oversight on my part is just another dead end. This would have been a supremely elegant solution to the problem, but it doesn't work.
GeneralRe: Saving image transform without losing metadata (NOT SOLVED: where is everybody?) Pin
fjparisIII30-Apr-09 15:01
fjparisIII30-Apr-09 15:01 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII2-May-09 17:16
fjparisIII2-May-09 17:16 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII3-May-09 16:53
fjparisIII3-May-09 16:53 
AnswerRe: Saving image transform without losing metadata Pin
Pete O'Hanlon4-May-09 9:12
mvePete O'Hanlon4-May-09 9:12 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII4-May-09 9:36
fjparisIII4-May-09 9:36 
GeneralRe: Saving image transform without losing metadata Pin
Pete O'Hanlon4-May-09 9:42
mvePete O'Hanlon4-May-09 9:42 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII4-May-09 9:58
fjparisIII4-May-09 9:58 
GeneralRe: Saving image transform without losing metadata Pin
Pete O'Hanlon4-May-09 10:06
mvePete O'Hanlon4-May-09 10:06 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII20-May-09 14:59
fjparisIII20-May-09 14:59 
GeneralRe: Saving image transform without losing metadata Pin
fjparisIII22-May-09 13:25
fjparisIII22-May-09 13:25 
QuestionCookies vs. isolated Storage Pin
Ray Cassick30-Apr-09 3:44
Ray Cassick30-Apr-09 3:44 
AnswerRe: Cookies vs. isolated Storage Pin
Mark Salsbery30-Apr-09 6:00
Mark Salsbery30-Apr-09 6:00 
AnswerRe: Cookies vs. isolated Storage Pin
GuinnessKMF4-May-09 3:28
GuinnessKMF4-May-09 3:28 
QuestionResource Dictionary and Data Templates Pin
BlitzPackage30-Apr-09 1:50
BlitzPackage30-Apr-09 1:50 
AnswerRe: Resource Dictionary and Data Templates Pin
User 2710091-May-09 4:56
User 2710091-May-09 4:56 
GeneralRe: Resource Dictionary and Data Templates Pin
BlitzPackage1-May-09 7:04
BlitzPackage1-May-09 7:04 
GeneralRe: Resource Dictionary and Data Templates Pin
User 2710091-May-09 7:11
User 2710091-May-09 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.