• 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: drawing 1 bit images, and image resolution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing 1 bit images, and image resolution


  • Subject: Re: drawing 1 bit images, and image resolution
  • From: Alex Zavatone <email@hidden>
  • Date: Fri, 10 Feb 2012 11:52:25 -0600

Let's work on this today and see what we get.  I've got meetings for the next 3 hours, but am free to try and help after that.

Feel free to email me in 3 hours.

Cool?

- Alex Zavatone

On Feb 10, 2012, at 11:15 AM, Chris Paveglio wrote:

> What I'm working with is a library that makes a QR code. It was built for iOS but I need desktop OSX (which, on a side note, seems silly because when you MAKE a qr code,  you'd usually want to print it right? Otherwise phones would just read them. Anyways...). It was easy enough to adjust the library to product an NSImage instead of UIImage. It's giving me an RGBa image (which is already BW, so I don't need to quantize... nor would I know how, that is way out of my league of skills I think). I don't want to fiddle around with the library so much because I'm afraid I will break it, and some of it's C++ and straight C. It would be great if it could output an greyscale image at least, instead of RBGa. But right now it doesn't so I will deal with the RGBa, and all channels are equal so I could use any.
> My C skills aren't so great, and I feel like if I can't make it all work properly, I wouldn't know if I had -any- of it working properly.
>
> After a while of studying and trying some things, here's what I've got so far. I know it's not correct and doesn't work yet.
>
> -(NSData *)oneBitData:(NSImage *)inputNSImage
> {
> NSData *testOnly = [NSData data];
> //this will be somewhat akin to un-reading the qrEncoder +renderDataMatrix method
> //I need to get 1 channel of the RGBa only here
> //or, change the library to return a greyscale image
> //output a 1 bit image of NSData format from an NSImage given in RGB mode
> //get an image rep from the current qrImage
> NSBitmapImageRep*imgRep = [NSBitmapImageRepimageRepWithData:[inputNSImage TIFFRepresentation]];
> int
> row, column,
> widthInPixels = [imgRep pixelsWide],
> heightInPixels = [imgRep pixelsHigh];
> //make a buffer of bits, like 50px x 50px = 2500 chars
> const int rawDataSize = widthInPixels * heightInPixels;
> unsigned char *rawData = (unsigned char*)malloc(rawDataSize);
> NSUInteger lePixel;
> for (row = 0; row < heightInPixels; row++)
> for (column = 0; column <widthInPixels; column++)
> {
> [imgRep getPixel:&lePixel atX:row y:column];
> //copy the value from first memory area to the same
> //location in the raw data area, it'll be either B or W, no inbetween values
> NSLog(@"bit %d = %d", (row * column) , lePixel);
> rawData[row * column] = lePixel < 128 ? 0 : 255;
> }
> return testOnly;
> }
>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: email@hidden)
 >Re: drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: Graham Cox <email@hidden>)
 >Re: drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)

  • Prev by Date: Re: drawing 1 bit images, and image resolution
  • Next by Date: Re: drawing 1 bit images, and image resolution
  • Previous by thread: Re: drawing 1 bit images, and image resolution
  • Next by thread: Re: drawing 1 bit images, and image resolution
  • Index(es):
    • Date
    • Thread