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 / Windows Forms / Drawing / April 2008

Tip: Looking for answers? Try searching our database.

Converting 8 bit indexed to 24bit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Linus - 31 Mar 2008 15:14 GMT
Hi,

Trying to convert 8bit indexed to 24bit I came across this:
The code below will NOT convert the indexed8 image to a 24bit image24,
(look below the code snipet)

       Dim image As Bitmap
       Dim image24 As Bitmap

       Try
           image = New Bitmap(filename)

           image24 = image.Clone(New Rectangle(0, 0,
image.width,image.height), Imaging.PixelFormat.Format24bppRgb)

       Catch
           image24 = Nothing
       End Try

but his WILL! Why does it convert the pixelformat if you just subtract
1 from the width????

       Dim image As Bitmap
       Dim image24 As Bitmap

       Try
           image = New Bitmap(filename)

           image24 = image.Clone(New Rectangle(0, 0,
image.width-1,image.height), Imaging.PixelFormat.Format24bppRgb)

       Catch
           image24 = Nothing
       End Try

Regards,
Linus
Michael Phillips, Jr. - 31 Mar 2008 15:32 GMT
The basic behavior of the Clone method is to provide you with an exact copy
of your source image.

If the rectangle to clone matches the extents of the source image, then you
get a copy with the same extents and pixel format.

If the rectangle to clone is different from the extents of the source image,
then the method must create a new image and convert it to match the
arguments which include a new pixel format.

> Hi,
>
[quoted text clipped - 33 lines]
> Regards,
> Linus
Michael C - 04 Apr 2008 05:25 GMT
> Hi,
>
> Trying to convert 8bit indexed to 24bit I came across this:
> The code below will NOT convert the indexed8 image to a 24bit image24,
> (look below the code snipet)

I think it's best to avoid using clone, it creates a copy that is somehow
linked to the original. I can't remember the exact details but I think I had
problems with disposing the images. Just create a new bitmap and use a
graphics object to draw the original onto the new one.

Michael

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.