All Projects → sokil → Php Bitmap

sokil / Php Bitmap

Licence: mit
Bitmap representation with bitwise operations

Projects that are alternatives of or similar to Php Bitmap

Pixelate
Simple Android library to pixelate images or certain areas of an image.
Stars: ✭ 602 (+8500%)
Mutual labels:  bitmap
Lambda Packages
Various popular python libraries, pre-compiled to be compatible with AWS Lambda
Stars: ✭ 713 (+10085.71%)
Mutual labels:  binary
Doramon
常见工具汇总:一键式生成整个前后端工具,单机高性能幂等工具,zookeeper客户端工具,分布式全局id生成器,一致性哈希工具,Bitmap工具,布隆过滤器参数生成器,Yaml和properties互转工具等等
Stars: ✭ 24 (+242.86%)
Mutual labels:  bitmap
Pbf
A low-level, lightweight protocol buffers implementation in JavaScript.
Stars: ✭ 618 (+8728.57%)
Mutual labels:  binary
Softmaskforugui
UI Soft Mask is a smooth masking component for Unity UI (uGUI) elements.
Stars: ✭ 688 (+9728.57%)
Mutual labels:  mask
Scientifica
tall, condensed, bitmap font for geeks.
Stars: ✭ 821 (+11628.57%)
Mutual labels:  bitmap
Angr
A powerful and user-friendly binary analysis platform!
Stars: ✭ 5,542 (+79071.43%)
Mutual labels:  binary
Frosty
serialize native Nim types to strings, streams, or sockets ⛄
Stars: ✭ 25 (+257.14%)
Mutual labels:  binary
Scodec
Scala combinator library for working with binary data
Stars: ✭ 709 (+10028.57%)
Mutual labels:  binary
Zpix Pixel Font
Zpix (最像素) is a pixel font supporting English, Traditional Chinese, Simplified Chinese and Japanese.
Stars: ✭ 916 (+12985.71%)
Mutual labels:  bitmap
Quickshot
Capture images of any View, SurfaceView or Bitmap from your Android app in: .jpg .png or .nomedia with simple oneliner codes.
Stars: ✭ 663 (+9371.43%)
Mutual labels:  bitmap
Instacapture
Android library to capture screenshot from your app
Stars: ✭ 681 (+9628.57%)
Mutual labels:  bitmap
Binary.dart
Utilities for working with binary data and bit manipulation in Dart.
Stars: ✭ 16 (+128.57%)
Mutual labels:  binary
Garble
Obfuscate Go builds
Stars: ✭ 617 (+8714.29%)
Mutual labels:  binary
Nativescript Masked Text Field
#️⃣ A NativeScript Masked Text Field widget
Stars: ✭ 24 (+242.86%)
Mutual labels:  mask
Masked Edittext
Android library contain custom realisation of EditText component for masking and formatting input text
Stars: ✭ 592 (+8357.14%)
Mutual labels:  mask
Ngx Mask
Angular Plugin to make masks on form fields and html elements.
Stars: ✭ 772 (+10928.57%)
Mutual labels:  mask
Nn mask
multichannel linear filters based on mask estimation neural networks for CHiME4
Stars: ✭ 26 (+271.43%)
Mutual labels:  mask
React Native Text Input Mask
Text input mask for React Native, Android and iOS
Stars: ✭ 922 (+13071.43%)
Mutual labels:  mask
Bits
A bite sized library for dealing with bytes.
Stars: ✭ 16 (+128.57%)
Mutual labels:  binary

php-bitmap

Total Downloads Daily Downloads Build Status

Bitmap, also called bit array is a data structure that compactly store set of values as bits of integer. More data can be read at http://en.wikipedia.org/wiki/Bit_array.

It is useful when required compact way to represent combination of values and simple manipulations with them. One byte can represent eight independent values.

Installation

{
    "require": {
        "sokil/php-bitmap": "1.0"
    }
}

Useage

Lets see example. Errors in PHP represents as constants:

E_ERROR = 1 (0);
E_WARNING = 2 (1);
E_PARSE = 4 (2);
E_NOTICE = 8 (3);
E_CORE_ERROR = 16 (4);
E_CORE_WARNING = 32 (5);
E_COMPILE_ERROR = 64 (6);
E_COMPILE_WARNING = 128 (7);
E_USER_ERROR = 256 (8);
E_USER_WARNING = 512 (9);
E_USER_NOTICE = 1024 (10);
E_STRICT = 2048 (11);
E_RECOVERABLE_ERROR = 4096 (12);
E_DEPRECATED = 8192 (13);
E_USER_DEPRECATED = 16384 (14);
E_ALL = 32767 (15);

Every error level represent logical "1", and combination of all this values may be represent only by two bytes. E_ERROR represent first bit of byte, E_WARNING - second, etc.

Combination of E_WARNING and E_NOTICE in binary system is "1010" or 10 in decimal system.

Class that represents bitmap of PHP errors:

class PhpError extends \Sokil\Bitmap
{
    /**
     * Show errors
     * Set first bit, which represents E_ERROR, to "1"
     */
    public function showErrors()
    {
        $this->setBit(0);
        return $this;
    }

    /**
     * Hide errors
     * Set first bit, which represents E_ERROR, to "0"
     */
    public function hideErrors()
    {
        $this->unsetBit(0);
        return $this;
    }

    /**
     * Check if errors shown
     * Check if first bit set to 1
     */
    public function isErrorsShown()
    {
        return $this->isBitSet(0);
    }

    /**
     * Show warnings
     * Set second bit, which represents E_WARNING, to "1"
     */
    public function showWarnings()
    {
        $this->setBit(1);
        return $this;
    }

    /**
     * Hide warnings
     * Set second bit, which represents E_WARNING, to "0"
     */
    public function hideWarnings()
    {
        $this->unsetBit(1);
        return $this;
    }

    /**
     * Check if warnings shown
     * Check if second bit set to 1
     */
    public function isWarningsShown()
    {
        return $this->isBitSet(1);
    }
}

Now we can easely manipulate with errors:

// load current error levels
$error = new PhpError(error_reporting());

// enable errors and warnings
$error->showErrors()->showWarnings();

// set error reporting
error_reporting($error->toInt());

// check if warnings shown
var_dump($error->isWarningsShown());

// value may be set by mask
// E_USER_ERROR | E_USER_WARNING is 256 + 512;
$error->setBitsByMask(E_USER_ERROR | E_USER_WARNING);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].