0

Possible Duplicate:
Convert RenderTargetBitmap to BitmapImage

I need to perform the convertion RenderTargetBitmap -> BitmapImage. What is the way to do that?

Thank you in advance!

Cheers

Community
  • 1
  • 1
Jamie
  • 1,092
  • 3
  • 22
  • 44
  • Not sure why it got a -1; it seems to be a common enough quesiton. There is an actual answer over at: http://stackoverflow.com/questions/13987408/convert-rendertargetbitmap-to-bitmapimage – Jesse Chisholm Jan 11 '13 at 21:40
  • Since my answer is very low quality I've voted to close this question as a duplicate in favour of the version linked to by @JesseChisholm – Martin Harris Jan 14 '13 at 09:52

1 Answers1

2

BitmapImage and RenderTargetBitmap both inherit directly from BitmapSource. The functionality that BitmapImage supplies over BitmapSource is just for ease of loading from an URI. I can't think of any scenario where you would need a BitmapImage rather than a BitmapSource (which RenderTargetBitmap already is) after you already have the image loaded / rendered.

What specifically are you trying to do?

Martin Harris
  • 28,277
  • 7
  • 90
  • 101
  • I need to combine two images, jpg and png and then use the resulting bitmap – Jamie Jul 29 '10 at 10:52
  • Which method / class are you trying to use to do this that only takes in an BitmapImage and not a BitmapSource? I guess if you really need to you could save the resultant bitmap out to a temp file and load it back in, but I don't think you will be able to go directly from RenderTargetBitmap to BitmapImage since a BitmapImage requires a file to load from. – Martin Harris Jul 29 '10 at 11:02
  • Well, I have got two BitmapImages and I uses Grid to combine them. Finally, RenderTargetBitmap renders this Grid, thus I need to go from RTB to BitmapImage again. Do you have any other idea? – Jamie Jul 29 '10 at 11:06
  • Sorry, I guess I'm still not understanding. You say "thus I need to go from RTB to BitmapImage again", but for what? What are you trying to do with the BitmapImage that you can't do directly on the RTB? – Martin Harris Jul 29 '10 at 12:41
  • Not what the questioner is trying to do, but you cannot set RTB.Rotation and you can set BI.Rotation. If you have an RTB but you want to rotate it, you need to convert it to a BitmapImage first. – Jesse Chisholm Jan 11 '13 at 21:10
  • 1
    Also, you cannot BI.Render but you can RTB.Render, so the fact they are both BitmapSource is immaterial. There are things you can do with one that you can't do with the other. There _ought_ to be a new BitmapImage(rtb) and a new RenderTargetBitmap(bi). – Jesse Chisholm Jan 11 '13 at 21:33