‘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???
why you get different results on different OS versions.
Anyway, here is a low-level (and ugly) workaround. It’s designed for JPEG images:
You need to replace this line
with this:
Finally, I haven’t tested this code with CMYK JPEG images, but I guess it should work…