Click here to Skip to main content
15,906,625 members
Home / Discussions / C#
   

C#

 
GeneralBinding multiple file collections to a form control Pin
Member 52585820-Sep-03 19:01
Member 52585820-Sep-03 19:01 
GeneralRe: Binding multiple file collections to a form control Pin
Blake Coverett20-Sep-03 20:12
Blake Coverett20-Sep-03 20:12 
Generalinterrupt mousemove or scrollbar Pin
novachen20-Sep-03 18:43
novachen20-Sep-03 18:43 
Generali want the code of to upload file with c# Pin
182720-Sep-03 14:39
182720-Sep-03 14:39 
GeneralGetting nested User Control item instance Pin
n3d3us20-Sep-03 13:15
n3d3us20-Sep-03 13:15 
GeneralRe: Getting nested User Control item instance Pin
n3d3us20-Sep-03 13:56
n3d3us20-Sep-03 13:56 
QuestionSockets: Threaded & Async? Pin
oblius20-Sep-03 12:43
oblius20-Sep-03 12:43 
AnswerRe: Sockets: Threaded & Async? Pin
Blake Coverett20-Sep-03 14:01
Blake Coverett20-Sep-03 14:01 
GeneralRe: Sockets: Threaded & Async? Pin
oblius20-Sep-03 14:11
oblius20-Sep-03 14:11 
GeneralRe: Sockets: Threaded & Async? Pin
Blake Coverett20-Sep-03 15:10
Blake Coverett20-Sep-03 15:10 
GeneralRe: Sockets: Threaded & Async? Pin
oblius20-Sep-03 16:20
oblius20-Sep-03 16:20 
GeneralMessage Queue Pin
ravfingcoder20-Sep-03 5:22
ravfingcoder20-Sep-03 5:22 
GeneralDigital Signature Pin
ravfingcoder20-Sep-03 4:11
ravfingcoder20-Sep-03 4:11 
Questionhow do you retrieve IP address and host name again? Pin
ravfingcoder20-Sep-03 4:06
ravfingcoder20-Sep-03 4:06 
AnswerRe: how do you retrieve IP address and host name again? Pin
leppie20-Sep-03 8:49
leppie20-Sep-03 8:49 
GeneralRe: how do you retrieve IP address and host name again? Pin
devvvy20-Sep-03 10:49
devvvy20-Sep-03 10:49 
GeneralRe: how do you retrieve IP address and host name again? Pin
zhouao22-Sep-03 19:07
zhouao22-Sep-03 19:07 
GeneralHidden Columns in ListView Pin
aka the guy20-Sep-03 3:44
aka the guy20-Sep-03 3:44 
GeneralRe: Hidden Columns in ListView Pin
Wjousts21-Sep-03 10:29
Wjousts21-Sep-03 10:29 
GeneralRe: Hidden Columns in ListView Pin
aka the guy21-Sep-03 14:06
aka the guy21-Sep-03 14:06 
GeneralNetwork Programming... Pin
fadee20-Sep-03 1:52
fadee20-Sep-03 1:52 
GeneralRe: Network Programming... Pin
Blake Coverett20-Sep-03 14:45
Blake Coverett20-Sep-03 14:45 
Oh my... it's hard to tell where to start. Since you start off with a comment about 'good and efficient', the first big issue is there is no reason to load those bits into a Bitmap object on both the server and the client just to do a file transfer. The short answer is, stop doing that and just transfer the bits directly.

Why it breaks the way it does is actually interesting. So here's the long answer for those interested.

Bitmap, like the rest of System.Drawing, is mostly a thin wrapper of the unmanaged GDI+ library. With that constructor you are eventually invoking the GdipCreateBitmapFromStream(IStream, GpBitmap*) API. The 'flat' GdiPlus functions aren't documented to my knowledge, but a the C++ wrappers around them are. (System.Drawing doesn't use those C++ wrappers, it calls the flat functions directly.)

If you have a look at the unmanaged GDI+ documentation for Bitmap::FromStream() you'll notice that the stream you are loading from must be seekable. The managed wrapper hides this. Unfortunately it doesn't hide it in a perfect way. If the stream is not seekable it slurps the _entire_ stream into memory and then calls GdipCreateBitmapFromStream on a seekable memory stream formed on those bits. This is a design bug in my opinion, and they should have just throw an exception when handed a non-seekable stream.

Oh, and the ALL CAPS VARIABLE NAMES have just got to go too, btw.

--
-Blake (com/bcdev/blake)
GeneralRe: Network Programming... Pin
fadee21-Sep-03 17:13
fadee21-Sep-03 17:13 
GeneralCom interop Pin
Abhijit Desai20-Sep-03 0:24
Abhijit Desai20-Sep-03 0:24 
GeneralmciSendString Question in C#,Please Help me! Pin
zoujiaming19-Sep-03 22:12
zoujiaming19-Sep-03 22:12 

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.