Solved

Inverting and decreasing colors in bitmap...

Posted on 2000-03-09
7
332 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now