I have managed to get to some point but I seem to always get an empty(0
bytes) png file.

unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls,
  StdCtrls, gdk, gdkpixbuf, gdk2pixbuf, gdk2, glib2;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1; 

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
 desktop : PGdkWindow;
 screenshot : PGdkPixbuf;
 w, h : longint;
 err : PPGError;
begin
 desktop := gdk_get_default_root_window;
 w := screen.Width;
 h := screen.Height;
 screenshot:=gdk_pixbuf_get_from_drawable(screenshot, desktop,
gdk_window_get_colormap(desktop) , 0, 0, 0, 0, w, h);
 gdk_pixbuf_save(screenshot, pchar('/home/cyberpython/01.png'),
pchar('png') , err);
end;

initialization
  {$I unit1.lrs}

end.
     

_______________________________________________
Lazarus mailing list
[email protected]
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to