• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get image real number of bits per pixel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get image real number of bits per pixel


  • Subject: Re: How to get image real number of bits per pixel
  • From: "Sebastien TOPIN" <email@hidden>
  • Date: Thu, 27 Feb 2003 10:07:44 +0100

Thanks for your help,
Maybe I am doing something wrong, but when I try to check the colorSpaceName
on my NSBitmapImageRep, I get a "NSCalibratedRGBColorSpace" which is the
default value and does not tell me that this is a grayscale 8 bits picture.

Here is a part of my code:
//========================================
NSBitmapImageRep *myImageRep = [NSBitmapImageRep
imageRepWithContentsOfFile:@"myGrayscaleFile.bmp"];
NSString *myColorNameSpace = [myImageRep colorSpaceName];
int iBitsPerPixel = [myImageRep bitsPerPixel];
...
//========================================

and I get:
colorSpaceName = "NSCalibratedRGBColorSpace"
iBitsPerPixel = "24"


I start to wonder if I going to be able to do this simple thing with
Cocoa...?
Seb

----- Original Message -----
From: "Jeff Disher" <email@hidden>
To: "Sebastien TOPIN" <email@hidden>
Sent: Thursday, February 27, 2003 3:01 AM
Subject: Re: How to get image real number of bits per pixel


> Get the colour space name of the NSBitmapImageRep to make sure that it
> actually is a grayscale image. I know that I have been able to open
> grayscale GIFs and correctly get the number of bits per pixel but they
> do report as being in the white colour space.
>
> This way you can at least find out what colour space it is loaded into.
>
> Just an idea,
> Jeff.
>
>
> On Wednesday, February 26, 2003, at 10:04 AM, Sebastien TOPIN wrote:
>
> > I am still not able to get the "real" number of bits per pixel from my
> > bmp
> > image.
> > I tried to create an NSBitmapImageRep object from [NSBitmapImageRep
> > WithContentOfFile:filename] and when I check the bitsPerPixel or
> > samplePerPixel value I still have 24 or 32 for a 8 bits gray scale
> > image.
> > Do I have to use QuickTime component to get this kind of information
> > or is
> > there a way to do it with Cocoa?
> >
> > BTW, I am new to Cocoa (and even to Mac I was on Visual Studio last
> > week!)
> > and I do apologise in advance if I ask stupid questions...
> > Seb
> >
> > ----- Original Message -----
> > From: "Marco Binder" <email@hidden>
> > To: "Sebastien TOPIN" <email@hidden>
> > Cc: "Cocoa List" <email@hidden>
> > Sent: Tuesday, February 25, 2003 6:25 PM
> > Subject: Re: How to get image real number of bits per pixel
> >
> >
> >> I guess you can ask the NSImageView for the path of the dropped file
> >> (please see docs yourself- I m busy at the moment). With the path, you
> >> can then instantiate a new NSBitmapImageRep. I know, this is waste of
> >> memory (TWO bitmap reps of the same image), but I could not yet figure
> >> out another way. You could of course subclass NSImageView and
> >> intercept
> >> the file-drop. Then set up a NSBitmapImageRep and add it to a newly
> >> created NSImage. Supply then this image as an argument when calling
> >> [myImageViewObject setImage:newlyCreatedImage].
> >>
> >> marco
> >>
> >>
> >> Am Dienstag, 25.02.03 um 18:14 Uhr schrieb Sebastien TOPIN:
> >>
> >>> Thanks but how do you get the image data? Is it directly from the
> >>> file?
> >>> I was trying to use the drag'n drop functionality (drag an image from
> >>> the
> >>> Finder to your application image control) in order to open my image
> >>> file. In
> >>> this case I already get an instantiated NSBitmapImageRep from
> >>> NSImageView
> >>> and just extract its parameters. This is what gives me the 32 bits
> >>> per
> >>> pixel.
> >>>
> >>>
> >>> ----- Original Message -----
> >>> From: "Marco Binder" <email@hidden>
> >>> To: "Sebastien TOPIN" <email@hidden>
> >>> Cc: <email@hidden>
> >>> Sent: Tuesday, February 25, 2003 5:57 PM
> >>> Subject: Re: How to get image real number of bits per pixel
> >>>
> >>>
> >>>> Directly instantiate an NSBitmapImageRep with the image-data and
> >>>> call
> >>>> the method. As to my experience, Cocoa will always use 8-bit RGBA to
> >>>> display images in an NSImageView.
> >>>>
> >>>> marco
> >>>>
> >>>>
> >>>> Am Dienstag, 25.02.03 um 17:21 Uhr schrieb Sebastien TOPIN:
> >>>>
> >>>>> Hi Folks,
> >>>>>
> >>>>> I am trying to get the real number of bits per pixel for a
> >>>>> displayed
> >>>>> image.
> >>>>> A NSImageView object enables me to drag n' drop a bmp image from
> >>>>> the
> >>>>> Finder
> >>>>> and display it in my app.
> >>>>> Then I got an NSBitmapImageRep from the NSImageView and did that:
> >>>>>
> >>>>> int iBitsPerPix = [bittmapImageRep bitsPerPixel];
> >>>>>
> >>>>> The result is always 32 even for grayscale 8 bits per pixel images
> >>>>> or
> >>>>> 24 bits
> >>>>> per pixel color images.
> >>>>>
> >>>>> How can I get the image real number of bits per pixel of those
> >>>>> images?
> >>>>>
> >>>>> Thanks in advance,
> >>>>> Seb
> >>>>> _______________________________________________
> >>>>> cocoa-dev mailing list | email@hidden
> >>>>> Help/Unsubscribe/Archives:
> >>>>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> >>>>> Do not post admin requests to the list. They will be ignored.
> >>>>>
> >>>>>
> >>>> --
> >>>> |\ /| E-Mail: email@hidden WWW: www.marco-binder.de
> >>>> | \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
> >>>> | |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
> >>>> BINDER _____________________________________________________
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >> --
> >> |\ /| E-Mail: email@hidden WWW: www.marco-binder.de
> >> | \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
> >> | |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
> >> BINDER _____________________________________________________
> > _______________________________________________
> > cocoa-dev mailing list | email@hidden
> > Help/Unsubscribe/Archives:
> > http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> > Do not post admin requests to the list. They will be ignored.
> >
> >
> Jeff Disher
> President and Lead Developer of Spectral Class
> Spectral Class: Shedding Light on Innovation
> http://www.spectralclass.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How to get image real number of bits per pixel
      • From: Marco Binder <email@hidden>
  • Prev by Date: Obj-C Code beautifier, where to get one?
  • Next by Date: Re: Overriding mouseDown in NSTableView
  • Previous by thread: Re: How to get image real number of bits per pixel
  • Next by thread: Re: How to get image real number of bits per pixel
  • Index(es):
    • Date
    • Thread