Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guys
i want to know how can i convert the binarywriter to stream or binarywriter to a bitmap
best regards
Posted
Comments
Sergey Alexandrovich Kryukov 21-Mar-12 18:09pm    
What is broken? MSDN? Google? Bing?
--SA

1 solution

You cannot "convert" them. The whole notion makes no sense.

First: System.IO.BinaryWriter vs. System.IO.Stream. First class is a specialized wrapper (binary, write-only) over the second one. Please see:
http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx[^].

Do I have to explain more? (Sigh…) Silence? I can see in your eyes that I better do. OK. You can construct a writer out of the instance of the Stream and/or later get this instance using System.IO.BinaryWriter.BaseStream:
http://msdn.microsoft.com/en-us/library/atxb4f07.aspx[^],
http://msdn.microsoft.com/en-us/library/d4w83hdt.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.binarywriter.basestream.aspx[^].

A Bitmap now? The System.Drawing.Bitmap is System.Drawing.Image, please see:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx[^].

You can use Image methods (see above) to work with streams; please locate FromStream and Save method in the MSDN article referenced above.

That's it. No "conversions".

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900