{
   This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}

unit Ufrmgif;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, gifimage, StdCtrls, ExtCtrls, Buttons, Menus, clipbrd;

type
  Tfrmgif = class(TForm)
    Image2: TImage;
    Panel1: TPanel;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    procedure FormShow(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure N1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    gif:tgifimage;
  end;

var
  frmgif: Tfrmgif;

implementation
uses Ufrmmain;
{$R *.dfm}

procedure Tfrmgif.FormShow(Sender: TObject);
var
  i,w,h:integer;
  pt:tpoint;
begin
  ComboBox1.Items.Clear;
  for i:=0 to gif.Images.Count-1 do begin
    self.ComboBox1.Items.Add(format('%d¹ø ÀÌ¹ÌÁö',[i+1]))
  end;
  w:=gif.Width;
  h:=gif.Height;

  self.ClientWidth:=w;
  if self.ClientWidth<263 then self.ClientWidth:=263;
  self.ClientHeight:=h+panel1.Height;

  image2.Left:=0;
  image2.Top:=panel1.Height;
  image2.Width:=w;
  image2.Height:=h;

  ComboBox1.ItemIndex:=0;
  ComboBox1Change(nil);

  pt:=frmmain.panelgif.ClientToScreen(point(0,0));
  Left:=pt.X;
  Top:=(pt.Y+frmmain.panelgif.Height)-self.Height;
end;

procedure Tfrmgif.ComboBox1Change(Sender: TObject);
var
  w,h,l,t:integer;
begin
  w:=gif.Width;
  h:=gif.Height;
  l:=gif.Images.SubImages[ComboBox1.ItemIndex].Left;
  t:=gif.Images.SubImages[ComboBox1.ItemIndex].Top;

  image2.Picture.Bitmap.Width:=w;
  image2.Picture.Bitmap.Height:=h;
  image2.Picture.Bitmap.Canvas.Brush.Color:=clbtnface;
  image2.Picture.Bitmap.Canvas.FillRect(rect(0,0,w,h));
  image2.Picture.Bitmap.Canvas.Draw(l,t,gif.Images.SubImages[ComboBox1.ItemIndex].Bitmap);
end;

procedure Tfrmgif.N1Click(Sender: TObject);
begin
  clipboard.Assign(gif.Images.SubImages[ComboBox1.ItemIndex].Bitmap);
end;

end.
