Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1484 connectés 

 


Dernière réponse
Sujet : Capture d'ecran VC++
darkoli tiens j'ai pu retrouver ce code
 
en gros je fais des dessin sur le bureau en le faisant passer pour un canvas. Donc je peux utiliser toutes les méthodes de la classe TCanvas
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    PaintBox1: TPaintBox;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Déclarations privées}
    bureau:TCanvas;
  public
    { Déclarations publiques}
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.DFM}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  bureau := TCanvas.Create;
  bureau.Handle := GetDC(hWnd_Desktop);
end;
 
procedure TForm1.Button1Click(Sender: TObject);
Var h,ht:longint;
begin
  bureau.Pen.Color := clWhite;
  bureau.Font.Name := 'Courier New';
  bureau.Font.Size := Trunc(Screen.Width / 6.4);
  ht := bureau.TextHeight('Blaireu');
  h := 0;
  while ( h < Screen.Height ) do
    begin
      bureau.Textout(0,h,'Blaireau');
      h := h + ht;
    end;
  Form1.Hide;
  Form1.Show;
end;
 
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{  bureau.Pen.Color := clBlack;
  bureau.FillRect(Rect(0,0,Screen.Width-1,Screen.Height-1));
}end;
 
procedure TForm1.Button2Click(Sender: TObject);
Var c,r,v,b:longint;
    nx,ny:longint;
    px,py:longint;
    bx,by:longint;
    nb:longint;
    x,y:longint;
    tmp:array [0..319,0..239] of longint;
begin
 // zomm inverse
  { initialisation }
  PaintBox1.Canvas.CopyRect(Rect(0,0,320,240),bureau,Rect(0,0,Screen.Width,Screen.Height));
{  nx := Screen.Width div 320;
  ny := Screen.Height div 200;
  for x := 0 to 319 do
    for y := 0 to 239 do
      begin
        px := nx * x;
        py := ny * y;
        r := 0;
        v := 0;
        b := 0;
        nb := 0;
        for bx := px to (px+nx - 1) do
          for by := py to (py+ny - 1) do
            begin
              inc(nb);
              c := bureau.Pixels[bx,by];
              r := r + ((c shr 16) and 255);
              v := v + ((c shr 8) and 255);
              b := b + ( c and 255);
            end;
        r := r div nb;
        v := v div nb;
        b := b div nb;
        tmp[x,y] := (r shl 16) + (v shl 8) + b;
      end;
  for x := 0 to 319 do
    for y := 0 to 239 do
      PaintBox1.Canvas.Pixels[x,y] := tmp[x,y];}
end;
 
end.

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
darkoli tiens j'ai pu retrouver ce code
 
en gros je fais des dessin sur le bureau en le faisant passer pour un canvas. Donc je peux utiliser toutes les méthodes de la classe TCanvas
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    PaintBox1: TPaintBox;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Déclarations privées}
    bureau:TCanvas;
  public
    { Déclarations publiques}
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.DFM}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  bureau := TCanvas.Create;
  bureau.Handle := GetDC(hWnd_Desktop);
end;
 
procedure TForm1.Button1Click(Sender: TObject);
Var h,ht:longint;
begin
  bureau.Pen.Color := clWhite;
  bureau.Font.Name := 'Courier New';
  bureau.Font.Size := Trunc(Screen.Width / 6.4);
  ht := bureau.TextHeight('Blaireu');
  h := 0;
  while ( h < Screen.Height ) do
    begin
      bureau.Textout(0,h,'Blaireau');
      h := h + ht;
    end;
  Form1.Hide;
  Form1.Show;
end;
 
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{  bureau.Pen.Color := clBlack;
  bureau.FillRect(Rect(0,0,Screen.Width-1,Screen.Height-1));
}end;
 
procedure TForm1.Button2Click(Sender: TObject);
Var c,r,v,b:longint;
    nx,ny:longint;
    px,py:longint;
    bx,by:longint;
    nb:longint;
    x,y:longint;
    tmp:array [0..319,0..239] of longint;
begin
 // zomm inverse
  { initialisation }
  PaintBox1.Canvas.CopyRect(Rect(0,0,320,240),bureau,Rect(0,0,Screen.Width,Screen.Height));
{  nx := Screen.Width div 320;
  ny := Screen.Height div 200;
  for x := 0 to 319 do
    for y := 0 to 239 do
      begin
        px := nx * x;
        py := ny * y;
        r := 0;
        v := 0;
        b := 0;
        nb := 0;
        for bx := px to (px+nx - 1) do
          for by := py to (py+ny - 1) do
            begin
              inc(nb);
              c := bureau.Pixels[bx,by];
              r := r + ((c shr 16) and 255);
              v := v + ((c shr 8) and 255);
              b := b + ( c and 255);
            end;
        r := r div nb;
        v := v div nb;
        b := b div nb;
        tmp[x,y] := (r shl 16) + (v shl 8) + b;
      end;
  for x := 0 to 319 do
    for y := 0 to 239 do
      PaintBox1.Canvas.Pixels[x,y] := tmp[x,y];}
end;
 
end.
nicog35 ouais ok, tu pourrais le copier coller dans les jours qui viennent ca serait sympa, merci d'avance
darkoli avec delphi c'est super facile. Tu crées un instance de l'objet TPaintBox (zone de dessin normalement) et ensuite tu choppes  le handle de la zonne de dessin du bureau avec une fonction de l'API Win32. Tu dis que l'instance que tu a créé a pour handle celui que tu as choppé et tu fais toto.saveToFile(je sais plus quelle est la méthode mais en gros ca prends au moins 3 4 ligne en delphi).
 
Malheureusement je ne peux pas etre plus précis ccar je ne m'en souvient plus (il y a 1 an deja) et le source n'est pas tout pret (environ 2km de la ou je suis maintenat)
nicog35 Comment le programmer ???
Mon logiciel devra faire une capture de l'ecran dans sa totalite et l'enregistrer au format bitmap sur support....

Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR