Link to home
Start Free TrialLog in
Avatar of Erik N
Erik N

asked on

Inverting and decreasing colors in bitmap...

I use the following to get a screen-capture. However, I want to decrease the colordepth, invert the colors and maybe decrease the resolution. Is this possible ?

Thanx !
/Erik N

procedure TForm3.BitBtn3Click(Sender: TObject);
var
    DC:HDC;
    Bmp:TBitmap ;
begin
    Application.minimize;
    sleep(Delay);
    DC:=getDC(GetDeskTopWindow);
    Bmp:=TBitmap.Create;
    Bmp.Width:=Screen.Width;
    Bmp.Height:=Screen.Height;
    BitBlt(Bmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,DC,0,0,SRCCOPY);
    Image1.Picture.Bitmap:=Bmp;
    ReleaseDC(DC,DC);
    Bmp.Free;
    Application.restore;
end;
Avatar of Epsylon
Epsylon

To reduce color try:

Image1.Picture.Bitmap.PixelFormat := pf8bit;


To resize set Image1.Stretch to true and change Image1.Width and Image1.Height
You can also use StretchBlt instead of BitBlt...
I never tried it but maybe InvertRect can be used to invert the colors.
BitBlt( Bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, 0, 0, 0, DSTINVERT ) ;

Will invert the colors...

As Epsylon said, StretchBlt will reduce the resoloution, and as for reducing colors, you might have to create another bitmap, set its pixelformat to whatever (as Epsylon said again), and then BitBlt the bitmap across...

If that doesn't work, then you are into some hefty color reduction algorythms (boo) ;O)

Good Luck,

Tim.
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, I forgot to strip-out the line

BitBlt(Bmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,DC,0,0,SRCCOPY);


Avatar of Erik N

ASKER

Nice !