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

Re: NSBitmapImageRep and 1-bit image


  • Subject: Re: NSBitmapImageRep and 1-bit image
  • From: Heinrich Giesen <email@hidden>
  • Date: Thu, 1 Dec 2005 11:24:39 +0100


On 01.12.2005, at 09:41, Timofey Sherudilo wrote:
Here is my problem: I try to create a 1-bit image representation, like this:

some text omitted

Do I create the monochrome image right? Is something wrong in my code?

You didn't respect that a pixel needs one BIT not one BYTE !
This leads to some "nice" bitoperations:
In the creation of imageRep you should write bytesPerRow:0
or bytesPerRow:(width+7)/8 and not bytesPerRow:width.

The offset in -setPicColor:... is
int offset = x/8 + [imageRep bytesPerRow] * y; // x/8 NOT x
Somewhere in planeBitmap[offset] is the bit that shall become
1 or 0. To be precise, it is the bitnumber x%8 (the modulo
operation) counting from left. If you have black = (...) ? 1 : 0;
you can set the pixel (==bit)

if( black==0 )
planeBitmap[offset] &= ~(0x80 >> (x%8)); // clear
else
planeBitmap[offset] |= 0x80 >> (x%8); // set


--
Heinrich Giesen
email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: NSBitmapImageRep and 1-bit image
      • From: Timofey Sherudilo <email@hidden>
  • Prev by Date: Re: Window layering and save sheet attachment in multi-window document
  • Next by Date: Re: NSBitmapImageRep and 1-bit image
  • Previous by thread: Re: NSBitmapImageRep and 1-bit image
  • Next by thread: Re: NSBitmapImageRep and 1-bit image
  • Index(es):
    • Date
    • Thread