»»»»»BitBlt frames o q esta errado? SIMPLES«««««««
17/05/2003
0
olha só sou iniciante e tava tentando fazer um exemplo simples de uma imagem com frames mais não deu certo vejão o codigo
lembrando q a imagem tem 16 de altura e 101 de largura e são 6 frames
Código:
Desde já obrigado
lembrando q a imagem tem 16 de altura e 101 de largura e são 6 frames
Código:
public { Public declarations } end; var Form1: TForm1; bmp: Tbitmap; tela :array [0..6] of tbitmap; y: integer = 0; implementation {$R *.DFM} procedure criarImagens(nome:string; frame:integer); var i:integer; begin i:= frame; bmp:= tbitmap.Create; bmp.loadfromfile(nome); tela[i]:= tbitmap.Create; bitblt(tela[i].Canvas.Handle,0,0,16,16,bmp.Canvas.Handle,I*16,16,SrcCopy); form1.PaintBox1.Canvas.Draw(0,0,tela[i]); end; procedure TForm1.Button1Click(Sender: TObject); begin if y >= 6 then y := 0; inc(y); criarImagens(´imagem.bmp´,Y); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin bmp.free; end; end.
Desde já obrigado
Robotizar
Curtir tópico
+ 0
Responder
Posts
17/05/2003
Iskatrek
num testei naum, mas axo qla na funcao bitblt
certo:
bitblt(tela[i].Canvas.Handle,0,0,16,16,bmp.Canvas.Handle,I*16,[b:cf802078f4]0[/b:cf802078f4],SrcCopy);
errado:
bitblt(tela[i].Canvas.Handle,0,0,16,16,bmp.Canvas.Handle,I*16,[b:cf802078f4]16[/b:cf802078f4],SrcCopy); [/b]
certo:
bitblt(tela[i].Canvas.Handle,0,0,16,16,bmp.Canvas.Handle,I*16,[b:cf802078f4]0[/b:cf802078f4],SrcCopy);
errado:
bitblt(tela[i].Canvas.Handle,0,0,16,16,bmp.Canvas.Handle,I*16,[b:cf802078f4]16[/b:cf802078f4],SrcCopy); [/b]
Responder
18/05/2003
Iskatrek
tinha masi uns errin...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Bmp: TBitmap;
Tela: array[0..6] of TBitmap;
Y: Integer = 0;
implementation
{$R *.DFM}
procedure criarImagens(Nome: string; Frame: integer);
begin
Bmp := Tbitmap.Create;
Bmp.Loadfromfile(Nome);
Tela[Frame] := TBitmap.Create;
Tela[Frame].Width := 16;
Tela[Frame].Height := 16;
Bitblt(Tela[Frame].Canvas.Handle, 0, 0, 16, 16, bmp.Canvas.Handle, Frame * 16, 0, SrcCopy);
Form1.PaintBox1.Canvas.Draw(0, 0, Tela[Frame]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Inc(Y);
if Y > 6 then
Y := 0;
CriarImagens(´C:\Arquivos de programas\Trillian\users\default\downloads\ICQ\89160524\Imagem.bmp´, Y);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
I: Integer;
begin
Bmp.Free;
for I := 0 to 6 do
Tela[I].Free;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Bmp: TBitmap;
Tela: array[0..6] of TBitmap;
Y: Integer = 0;
implementation
{$R *.DFM}
procedure criarImagens(Nome: string; Frame: integer);
begin
Bmp := Tbitmap.Create;
Bmp.Loadfromfile(Nome);
Tela[Frame] := TBitmap.Create;
Tela[Frame].Width := 16;
Tela[Frame].Height := 16;
Bitblt(Tela[Frame].Canvas.Handle, 0, 0, 16, 16, bmp.Canvas.Handle, Frame * 16, 0, SrcCopy);
Form1.PaintBox1.Canvas.Draw(0, 0, Tela[Frame]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Inc(Y);
if Y > 6 then
Y := 0;
CriarImagens(´C:\Arquivos de programas\Trillian\users\default\downloads\ICQ\89160524\Imagem.bmp´, Y);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
I: Integer;
begin
Bmp.Free;
for I := 0 to 6 do
Tela[I].Free;
end;
end.
Responder
Clique aqui para fazer login e interagir na Comunidade :)