Solved

Inverting and decreasing colors in bitmap...

Posted on 2000-03-09
7
342 Views
Last Modified: 2010-04-04
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;
0
Comment
Question by:Erik N
  • 5
7 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2600206
To reduce color try:

Image1.Picture.Bitmap.PixelFormat := pf8bit;


To resize set Image1.Stretch to true and change Image1.Width and Image1.Height
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2600218
You can also use StretchBlt instead of BitBlt...
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2600221
I never tried it but maybe InvertRect can be used to invert the colors.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Expert Comment

by:AttarSoftware
ID: 2600273
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.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 200 total points
ID: 2601875
This works:


procedure TForm1.Button1Click(Sender: TObject);
var w,h:Integer;
    DC:HDC;
    Bmp:TBitmap ;
begin
    w:=500;
    h:=500;
    Visible := false;
    sleep(250);
    DC:=getDC(GetDeskTopWindow);
    Bmp:=TBitmap.Create;
    Bmp.Width:=w;
    Bmp.Height:=h;
    BitBlt    (Bmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,DC,0,0,SRCCOPY);
    StretchBlt(Bmp.Canvas.Handle,0,0,w,h,DC,0,0,Screen.Width,Screen.Height,SRCCOPY);
    InvertRect(Bmp.Canvas.Handle,Rect(0,0,w,h));
    Bmp.PixelFormat := pf8bit;
    Image1.Picture.Bitmap:=Bmp;
    ReleaseDC(DC,DC);
    Bmp.Free;
    Visible := true;
end;


Cheers,

Epsylon.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2601882
Oops, I forgot to strip-out the line

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


0
 

Author Comment

by:Erik N
ID: 2605124
Nice !
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question