Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Is there any example to display the image from the RGB source?Thanks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
linuxfedora@yahoo.com.hk - 29 Sep 2007 05:54 GMT
I have a function which will return the RGB source to me, then what i
want to do is to create the image and show the image on a Form. What
is the best way to do it? Is there any example for that?Thanks.
Peter Duniho - 29 Sep 2007 08:07 GMT
> I have a function which will return the RGB source to me, then what i
> want to do is to create the image and show the image on a Form. What
> is the best way to do it? Is there any example for that?Thanks.

That depends a bit on exactly what format the RGB source is.  If it is
already in a BMP format, or something that can be easily converted to
BMP format (see the Windows BITMAPFILEHEADER --
http://msdn2.microsoft.com/en-us/library/ms532321.aspx -- and related
documentation for specifics), then the simplest approach may be to just
write the data to a MemoryStream in the BMP file format, and then use
that MemoryStream as the input to Image.FromStream().

If there's a lot of conversion that you have to do anyway, it might make
more sense to create an appropriate byte array, and use the
Bitmap.LockBits() method to initialize a Bitmap (you can either use the
version that retrieves a buffer for the Bitmap into which you can copy
your data, or the version that allows you to provide the buffer which
you've already initialized from your data).

Either method will work, regardless of how much conversion there is to
do.  It just seems to me that if the data basically already looks like a
BMP file (with or without the header structures), the first method could
wind up being just a handful of lines of code, justifying the possible
extra overhead of going through the whole "copy to stream, init from
stream" stuff.

But I think the second method is probably a little more efficient.
Noting, of course, that I have not done any performance testing myself
to verify that.  It's just a theory.  :)

Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.