Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Color image rgb to negative

McManusMcManus Member Posts: 1
hi to all




can anyone help me i can't find anything !!!


thanks

Comments

  • PiSymbolPiSymbol Member Posts: 13
    Does this help?

    [code]
    Byte __fastcall customIntToByte(int i)
    {
    if(i > 255) return 255;
    else if(i < 0) return 0;
    else return i;
    }
    //---------------------------------------------------------------------------

    void __fastcall Invert(Graphics::TBitmap *Bitmap, bool Value)
    {
    Byte *p0;
    int r, g, b;
    for(int y=0; yHeight; y++)
    {
    p0 = (Byte *)Bitmap->ScanLine[y];
    for(int x=0; xWidth; x++)
    {
    r = p0[x * 3];
    g = p0[x * 3 + 1];
    b = p0[x * 3 + 2];

    // invert
    if(Value == true)
    {
    r = 255 - r;
    g = 255 - g;
    b = 255 - b;
    }

    p0[x * 3] = customIntToByte(r);
    p0[x * 3 + 1] = customIntToByte(g);
    p0[x * 3 + 2] = customIntToByte(b);
    }
    }
    }
    //---------------------------------------------------------------------------

    void __fastcall TForm1::Button1Click(TObject *Sender)
    { // Use function like this
    Invert(Image1->Picture->Bitmap, true);
    }
    //---------------------------------------------------------------------------
    [/code]

Sign In or Register to comment.