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

  • SEARCH
  • Home
  • 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 8341449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:29:01+00:00 2026-06-09T05:29:01+00:00

I want to create an image that is black and white so it is

  • 0

I want to create an image that is black and white so it is 1bpp. Right now this is my code that converts an image to black and white based on a threshold:

- (UIImage *)pureBlackAndWhiteImage:(UIImage *)image value:(float)value {

    unsigned char *dataBitmap = [self convertUIImageToBitmapRGBA8:image];

    for (int i = 0; i < image.size.width * image.size.height * 4; i += 4) {

        if ((dataBitmap[i + 0] + dataBitmap[i + 1] + dataBitmap[i + 2]) < value) {
            dataBitmap[i + 0] = 0;
            dataBitmap[i + 1] = 0;
            dataBitmap[i + 2] = 0;
        } else {
            dataBitmap[i + 0] = 255;
            dataBitmap[i + 1] = 255;
            dataBitmap[i + 2] = 255;
        }
    }
    image = [self convertBitmapRGBA8ToUIImage:dataBitmap withWidth:image.size.width withHeight:image.size.height];

    return image;
}

However this image is still 8bpp. How can I make it so that it is 1bpp?

  • 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-09T05:29:02+00:00Added an answer on June 9, 2026 at 5:29 am

    I don’t know what those methods are that you refer to, but the second does claim to produce an image from an RGBA data set, so why do you expect 1bpp?

    Frankly, I don’t know if iOS can even support 1bpp. If you cannot determine for sure that the answer is no, you’ll probably have to experiment.

    What you need to do is first render the existing RGBA image and get access to the pixels (as it appears you have done. You will then need to malloc a chunk of memory and write the image as you want – 1 bit per pixel. When you have that data you can get a CGImageRef using:

    CGImageRef CGImageCreate (
       size_t width,
       size_t height,
       size_t bitsPerComponent,
       size_t bitsPerPixel,
       size_t bytesPerRow,
       CGColorSpaceRef colorspace,
       CGBitmapInfo bitmapInfo,
       CGDataProviderRef provider,
       const CGFloat decode[],
       bool shouldInterpolate,
       CGColorRenderingIntent intent
    );
    

    and a UIImage from that.

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

Sidebar

Related Questions

I want to draw an alpha mask image in code. Right now I do:
I want to create a web page background image that fills the entire background,
I want to create a huge resolution Bitmap-image so that to load it into
I have an AsyncFacebookRunner that uploads an image to Facebook. I want to create
JavaScript. I want to create simple script, that will be resize loaded image using
i want create image animation , i have 50 images with png format now
I want to use this jQuery gallery more than once on my page: http://workshop.rs/2010/07/create-image-gallery-in-4-lines-of-jquery/
I use the following code with the intention to create an image that's half
I want to create some function for rendering images from within Joomla v1.5.23. That
I have a collection of string. I want to create an image out of

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.