<commit_before>//
//  MBBitmapPixelPlane.h
//  Mockingbird Toolbox
//
//  Created by <NAME> on 6/18/12.
//  Copyright (c) 2012 Gilt Groupe. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MBAvailability.h"

#if MB_BUILD_IOS
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
#endif

/******************************************************************************/
#pragma mark Types
/******************************************************************************/

/*!
 Indicates how an `MBBitmapPixelPlane` represents the color and alpha
 channels within the pixel data.
 
 These values govern how pixel channel data within the `MBBitmapPixel`
 struct should be interpreted.
 */
typedef NS_ENUM(NSUInteger, MBBitmapPixelType) {
    /*! The pixel type of the underlying bitmap is not known. `MBBitmapPixel`
        data is undefined and should not be relied upon. */
    MBBitmapPixelTypeUnknown,

    /*! The pixel type of the underlying bitmap is not compatible with the
        `MBBitmapPixelPlane` class. `MBBitmapPixel` data is undefined and 
        should not be relied upon. */
    MBBitmapPixelTypeIncompatible,

    /*! The bitmap uses the `alpha` channel (`channel4`) component of the
        `MBBitmapPixel` and no others. */
    MBBitmapPixelTypeAlpha,

    /*! The bitmap uses the `white` channel (`channel1`) and potentially the
        `alpha` channel (`channel4`) of the `MBBitmapPixel`. */
    MBBitmapPixelTypeMonochrome,
     
    /*! The bitmap uses the `red` (`channel1`), `green` (`channel2`) and `blue`
        (`channel3`) channels and potentially the `alpha` channel
        (`channel4`) of the `MBBitmapPixel`. */
    MBBitmapPixelTypeRGB
};

//!< use the `MBColorComponent` type for variables expressing color/alpha channel values
typedef unsigned char MBColorComponent;

/*!
 Provides a mechanism for accessing the color data for a single pixel.
 Correctly interpreting the color data requires knowing the associated
 `MBBitmapPixelPlane`'s `pixelType`.
 */
typedef struct {
    union
    {
        MBColorComponent red;
        MBColorComponent white;
        MBColorComponent channel1;
    };
    union
    {
        MBColorComponent green;
        MBColorComponent channel2;
    };
    union
    {
        MBColorComponent blue;
        MBColorComponent channel3;
    };
    union
    {
        MBColorComponent alpha;
        MBColorComponent channel4;
    };
} MBBitmapPixel;

/******************************************************************************/
#pragma mark -
#pragma mark MBBitmapPixelPlane class
/******************************************************************************/

/*!
 Represents a plane of pixels that can be accessed individually, regardless of
 the underlying pixel format. This allows code to access and manipulate bitmaps
 without needing to worry about the internal representation of the pixels.
 
 **Important:**
 
 * This class supports only integral pixels.
 * This class does not currently support floating-point channel values.
 * This class is only intended for use with iOS-compatible bitmaps.
 */
@interface MBBitmapPixelPlane : NSObject

/*----------------------------------------------------------------------------*/
#pragma mark Accessing bitmap information
/*!    @name Accessing bitmap information                                     */
/*----------------------------------------------------------------------------*/

/*! Returns the number of pixels in the bitmap. */
@property(nonatomic, readonly) NSUInteger pixelCount;

/*! Returns the number of columns in the bitmap. */<commit_msg>suppress compilation warning that occurs when<commit_after>//
//  MBBitmapPixelPlane.h
//  Mockingbird Toolbox
//
//  Created by <NAME> on 6/18/12.
//  Copyright (c) 2012 Gilt Groupe. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "MBAvailability.h"

#if MB_BUILD_IOS
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
#endif

/******************************************************************************/
#pragma mark Types
/******************************************************************************/

/*!
 Indicates how an `MBBitmapPixelPlane` represents the color and alpha
 channels within the pixel data.
 
 These values govern how pixel channel data within the `MBBitmapPixel`
 struct should be interpreted.
 */
typedef NS_ENUM(NSUInteger, MBBitmapPixelType) {
    /*! The pixel type of the underlying bitmap is not known. `MBBitmapPixel`
        data is undefined and should not be relied upon. */
    MBBitmapPixelTypeUnknown,

    /*! The pixel type of the underlying bitmap is not compatible with the
        `MBBitmapPixelPlane` class. `MBBitmapPixel` data is undefined and 
        should not be relied upon. */
    MBBitmapPixelTypeIncompatible,

    /*! The bitmap uses the `alpha` channel (`channel4`) component of the
        `MBBitmapPixel` and no others. */
    MBBitmapPixelTypeAlpha,

    /*! The bitmap uses the `white` channel (`channel1`) and potentially the
        `alpha` channel (`channel4`) of the `MBBitmapPixel`. */
    MBBitmapPixelTypeMonochrome,
     
    /*! The bitmap uses the `red` (`channel1`), `green` (`channel2`) and `blue`
        (`channel3`) channels and potentially the `alpha` channel
        (`channel4`) of the `MBBitmapPixel`. */
    MBBitmapPixelTypeRGB
};

//!< use the `MBColorComponent` type for variables expressing color/alpha channel values
typedef unsigned char MBColorComponent;

/*!
 Provides a mechanism for accessing the color data for a single pixel.
 Correctly interpreting the color data requires knowing the associated
 `MBBitmapPixelPlane`'s `pixelType`.
 */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
typedef struct {
    union
    {
        MBColorComponent red;
        MBColorComponent white;
        MBColorComponent channel1;
    };
    union
    {
        MBColorComponent green;
        MBColorComponent channel2;
    };
    union
    {
        MBColorComponent blue;
        MBColorComponent channel3;
    };
    union
    {
        MBColorComponent alpha;
        MBColorComponent channel4;
    };
} MBBitmapPixel;
#pragma clang diagnostic pop

/******************************************************************************/
#pragma mark -
#pragma mark MBBitmapPixelPlane class
/******************************************************************************/

/*!
 Represents a plane of pixels that can be accessed individually, regardless of
 the underlying pixel format. This allows code to access and manipulate bitmaps
 without needing to worry about the internal representation of the pixels.
 
 **Important:**
 
 * This class supports only integral pixels.
 * This class does not currently support floating-point channel values.
 * This class is only intended for use with iOS-compatible bitmaps.
 */
@interface MBBitmapPixelPlane : NSObject

/*----------------------------------------------------------------------------*/
#pragma mark Accessing bitmap information
/*!    @name Accessing bitmap information                                     */
/*----------------------------------------------------------------------------*/

/*! Returns the number of pixels in the bitmap. */
@property(nonatomic, readonly) NSUInteger pixelCount;

/*! Returns the number of columns in the bitmap. */
{'fraction_non_alphanumeric': 0.20049066375902957, 'fraction_numerical': 0.005724410522011721, 'mean_word_length': 2.9600647598488936, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3848231', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1720, 'n_words': 666}