convert image to bitmap
-
Hi, Is there a way to convert a
system.drawing.image
tosystem.drawing.bitmap
without having to save it to disk first. Would appreciate any good help thanks -
Hi, Is there a way to convert a
system.drawing.image
tosystem.drawing.bitmap
without having to save it to disk first. Would appreciate any good help thanksThere's three System.Drawing.Bitmap constructors that take a System.Drawing.Image as a parameter... Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
There's three System.Drawing.Bitmap constructors that take a System.Drawing.Image as a parameter... Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi, thanks for the reply. Im new with C# (started with TP and mainly work in php / MySQL) so constructors is all new to me... Been looking around and cant seem to find the right thing/way to do this. if i have
System.Drawing.Image modimage; System.Drawing.Bitmap modbitmap;
changes are first done to modimage and then i want to do something likemodbitmap = modimage;
and then carry on with changes to modbitmap. obviously themodbitmap = modimage;
does not work as it is like trying to saystrSomething = intSomethign;
it would be nice if there was a thing likemodbitmap = modimage.tobitmap();
lol anyway, my trials have proved fruitless so i am hoping that you would be kind enough to spare a min and help me out. thanks in advance.:cool: -
Hi, thanks for the reply. Im new with C# (started with TP and mainly work in php / MySQL) so constructors is all new to me... Been looking around and cant seem to find the right thing/way to do this. if i have
System.Drawing.Image modimage; System.Drawing.Bitmap modbitmap;
changes are first done to modimage and then i want to do something likemodbitmap = modimage;
and then carry on with changes to modbitmap. obviously themodbitmap = modimage;
does not work as it is like trying to saystrSomething = intSomethign;
it would be nice if there was a thing likemodbitmap = modimage.tobitmap();
lol anyway, my trials have proved fruitless so i am hoping that you would be kind enough to spare a min and help me out. thanks in advance.:cool:Try this: modbitmap = new System.Drawing.Bitmap(modimage);
-
Hi, thanks for the reply. Im new with C# (started with TP and mainly work in php / MySQL) so constructors is all new to me... Been looking around and cant seem to find the right thing/way to do this. if i have
System.Drawing.Image modimage; System.Drawing.Bitmap modbitmap;
changes are first done to modimage and then i want to do something likemodbitmap = modimage;
and then carry on with changes to modbitmap. obviously themodbitmap = modimage;
does not work as it is like trying to saystrSomething = intSomethign;
it would be nice if there was a thing likemodbitmap = modimage.tobitmap();
lol anyway, my trials have proved fruitless so i am hoping that you would be kind enough to spare a min and help me out. thanks in advance.:cool:Try what GrinderDev suggested ;) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi, thanks for the reply. Im new with C# (started with TP and mainly work in php / MySQL) so constructors is all new to me... Been looking around and cant seem to find the right thing/way to do this. if i have
System.Drawing.Image modimage; System.Drawing.Bitmap modbitmap;
changes are first done to modimage and then i want to do something likemodbitmap = modimage;
and then carry on with changes to modbitmap. obviously themodbitmap = modimage;
does not work as it is like trying to saystrSomething = intSomethign;
it would be nice if there was a thing likemodbitmap = modimage.tobitmap();
lol anyway, my trials have proved fruitless so i am hoping that you would be kind enough to spare a min and help me out. thanks in advance.:cool:You could also just cast it... (This is a bit faster and uses less memory).
bitmap = (Bitmap)image;
Matthew Butler
-
You could also just cast it... (This is a bit faster and uses less memory).
bitmap = (Bitmap)image;
Matthew Butler
Yes, most of the time that will work; what if the image happens to be a Metafile? :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Yes, most of the time that will work; what if the image happens to be a Metafile? :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
I've never used metafiles. ...but I suppose that would give an error. Do people still use wmf/emf? I've always concidered them quite an old (and outdated) format.
Matthew Butler
-
I've never used metafiles. ...but I suppose that would give an error. Do people still use wmf/emf? I've always concidered them quite an old (and outdated) format.
Matthew Butler
M. Butler wrote:
Do people still use wmf/emf?
I don't know. My point is:
(Bitmap)Image.FromFile("test.WMF")
could throw since there is a difference between Bitmap and Image classes, so I prefer either the constructor approach (hoping it is not too expensive) or an "is Bitmap" test (C#). :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
M. Butler wrote:
Do people still use wmf/emf?
I don't know. My point is:
(Bitmap)Image.FromFile("test.WMF")
could throw since there is a difference between Bitmap and Image classes, so I prefer either the constructor approach (hoping it is not too expensive) or an "is Bitmap" test (C#). :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Good example of why casts are dangerous. C# really allows casts? hehe
Mark Salsbery Microsoft MVP - Visual C++ :java: