Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8767473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:49:20+00:00 2026-06-13T16:49:20+00:00

‘ofd is open file dialog Dim img As Bitmap Dim iscmyk As Boolean Dim

  • 0

‘ofd is open file dialog

Dim img As Bitmap
Dim iscmyk As Boolean
Dim i As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    ofd.Filter = "Jpg Image(*.jpg)|*.jpg"
    If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
        img = Bitmap.FromFile(ofd.FileName)
        iscmyk = ((DirectCast(img.Flags, Imaging.ImageFlags) And Imaging.ImageFlags.ColorSpaceCmyk) = Imaging.ImageFlags.ColorSpaceCmyk)
    End If
    img = New Bitmap(img, New Size(120, 190))
    MsgBox("cmyk = " & iscmyk)
    PictureBox1.Image = img
End Sub

i need to check if the image is cmyk or rgb
if its cmyk then iscmyk returns true
if its not cmyk then iscmyk returns false
in my windows 7 pc its returns false for each & every image
but in XP it returns perfect answer

why its not working in my other win7 pcs???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:49:21+00:00Added an answer on June 13, 2026 at 4:49 pm
    • First, sorry for responding so late…
    • Second, actually I don’t know
      why you get different results on different OS versions.

    Anyway, here is a low-level (and ugly) workaround. It’s designed for JPEG images:

    Public Shared Function GetJpegBpp(FileName As String) As Integer
        Dim len As Integer
        Dim fp As FileStream = Nothing
        Dim marker(1) As Byte
        Dim data(15) As Byte
        Dim components As Byte = 0
    
        GetJpegBpp = -2
        Try
            fp = New FileStream(FileName, FileMode.Open, FileAccess.Read)
            GetJpegBpp = -1
            If fp.Read(marker, 0, 2) < 2 OrElse marker(0) <> &HFF OrElse marker(1) <> &HD8 Then Exit Function
            Do
                If fp.Read(marker, 0, 2) < 2 OrElse marker(0) <> &HFF OrElse (marker(1) > 1 And marker(1) < &HC0) Then Exit Function
                If (marker(1) < &HD0 Or marker(1) > &HD9) AndAlso marker(1) > 1 Then
                    If fp.Read(data, 0, 2) < 2 Then Exit Function
                    len = (CInt(data(0)) << 8) Or data(1)
                    len -= 2
                    If len < 0 Then Exit Function
                    If (marker(1) >= &HC0) And (marker(1) <= &HC3) Then
                        If len < 9 OrElse fp.Read(data, 0, 6) < 6 Then Exit Function
                        components = data(5)
                        If components = 0 OrElse components = 2 OrElse components > 4 OrElse (components * 3 + 6) <> len Then Exit Function
                        len -= 6
                    ElseIf marker(1) = &HDA Then
                        If len < (4 + 2 * components) Or (fp.ReadByte() <> components) Then Exit Function
                        len -= 1
                    End If
                    fp.Position += len
                End If
            Loop Until marker(1) = &HDA Or marker(1) = &HD9
            If components = 0 OrElse marker(1) = &HD9 OrElse (fp.Length - fp.Position) < 3 Then Exit Function
        Catch
            Exit Function
        Finally
            If Not fp Is Nothing Then fp.Close()
        End Try
        GetJpegBpp = components * 8
    End Function
    

    You need to replace this line

    iscmyk = ((DirectCast(img.Flags, Imaging.ImageFlags) And Imaging.ImageFlags.ColorSpaceCmyk) = Imaging.ImageFlags.ColorSpaceCmyk)
    

    with this:

    iscmyk = (GetJpegBpp(ofd.FileName) = 32)
    

    Finally, I haven’t tested this code with CMYK JPEG images, but I guess it should work…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I would like to count the length of a string with PHP. The string
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I have a reasonable size flat file database of text documents mostly saved in
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
The problem with unsigned char. I am reading a PPM image file which has
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.