Solved

Inverting and decreasing colors in bitmap...

Posted on 2000-03-09
7
322 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
Comment Utility
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
Comment Utility
You can also use StretchBlt instead of BitBlt...
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
I never tried it but maybe InvertRect can be used to invert the colors.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Expert Comment

by:AttarSoftware
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Nice !
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

12 Experts available now in Live!

Get 1:1 Help Now