Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inverting and decreasing colors in bitmap...

Posted on 2000-03-09
7
Medium Priority
?
378 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 800 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

636 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