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 2005

Tip: Looking for answers? Try searching our database.

Retrieve an image type (RGB, grayscale, CMYK)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 12 Sep 2005 04:34 GMT
Hi, part of my application uploads a file to a remote webserver. One of the
conditions is that the uploaded image *must be* a RGB JPEG

Does anyone have any idea how I can test to see if the uploaded image is a
RGB JPEG?

I looked at the PostedFile.getContentType() and this does tell me the type
of the file (JPEG) but not if the image was a RGB JPEG. The returned
information from the PostedFile.getContentType() also varies from browser to
browser

TIA
Mark
Lloyd Dupont - 12 Sep 2005 06:06 GMT
1st I beliebe that all JPG are RGB, aren't they?
anyway what about loading the image and check it's color type?

mmh.... maybe you don't know how?
here is an idea of pseudo-code-solution
bool IsMyImageType(Stream data)
{
   try
   {
       using(Bitmap bmp = new Bitmap(data))
       {
           if(!bmp.ImageFormat.Equals(ImageFormat.Jpeg))
               return false;
           switch(bmp.PixelFormat)
           {
               default:
                   return false;
               // as far as I believe only the 1st case is really needed
for a JPEG file
               case PixelFormat.Format32bppRgb:
               case PixelFormat.Format16bppArgb555:
               case PixelFormat.Format16bppRgb555:
               case PixelFormat.Format16bppRgb565:
               case PixelFormat.Format24bppRgb:
               case PixelFormat.Format24bppArgb:
               case PixelFormat.Format32bppAgb:
               case PixelFormat.Format32bppPArgb:
               case PixelFormat.Format48bppRgb:
               case PixelFormat.Format64bppArgb:
               case PixelFormat.Format64bppRgb:
                   return true;
           }
       }
       return bm
   }
   catch { return false; }
}
> Hi, part of my application uploads a file to a remote webserver. One of
> the
[quoted text clipped - 11 lines]
> TIA
> Mark
Mark - 13 Sep 2005 05:50 GMT
Hi, thanks for your help. I'll take a look at what you have recommended
below :)
Cheers
Mark
> 1st I beliebe that all JPG are RGB, aren't they?
> anyway what about loading the image and check it's color type?
[quoted text clipped - 48 lines]
> > TIA
> > Mark

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.