Fórum Thumbnails - como fazer ? #341417
08/05/2007
0
Estou utilizando Delphi 7.
Att.
Marcos.gandin
Curtir tópico
+ 0Posts
08/05/2007
Aloizio Castro
Isto onde?? DBGrid?? Listar todas as fotos de uma pasta no Form?!?
Gostei + 0
08/05/2007
Marcos.gandin
Gostei + 0
08/05/2007
Aloizio Castro
Pow, acho q tenho um codigo aqui, vou procurar e jah posto!! :wink:
Gostei + 0
08/05/2007
Marcos.gandin
Se puder me ajudar eu te agradeço muito.
Um abraço...
Gostei + 0
08/05/2007
Aloizio Castro
procedure CreateThumbs(Diretorio: String; ThumbSize: Word; Owner: TWinControl); var i: Word; Img: TImage; Ext: String; Arqs: TStrings; wTop, wLeft: Word; Obj: TObject; begin //-- Listar arquivos do diretorio Diretorio := IfThen(RightStr(Diretorio,1) <> ´\´ , Diretorio + ´\´ , Diretorio); Arqs := TShell.ListaArq(Diretorio); //-- Posição dos componentes wTop := 8; wLeft := 8; //-- Destruir componentes de thumbs antigo if Owner.ComponentCount > 0 then begin for i := Owner.ComponentCount-1 downto 0 do begin if (Owner.Components[i] is TImage) then if (Owner.Components[i] as TImage).Tag = 785 then begin Obj := Owner.Components[i]; FreeAndNil(Obj); end; end; end; //-- Exibir imagens if Arqs.Count > 0 then begin for i := 0 to Arqs.Count -1 do begin Ext := UpperCase(ExtractFileExt(Arqs[i])); if (Ext = ´.BMP´) or (Ext = ´.JPG´) or (Ext = ´.WMF´) or (Ext = ´.JPEG´) then begin Img := TImage.Create(Owner); Img.Parent := Owner; Img.Stretch := True; Img.Proportional := True; Img.Center := True; Img.Tag := 785; Img.Picture.LoadFromFile(Diretorio + Arqs[i]); Img.SetBounds(wLeft,wTop,ThumbSize,ThumbSize); //-- Pular linha qdo ultrapassar o width do scrollbox wLeft := ThumbSize + 8 + wLeft; if wLeft > Owner.Width then begin wLeft := 8; wTop := ThumbSize + 8 + wTop; end end; end; end; end; end.
Para listar o arquivo, use a função abaixo:
TShell = class
public
class function ListaArq(Caminho: string;Filtro : String = ´*.*´): TStrings;
end;
implementation
{ TShell }
class function TShell.ListaArq(Caminho, Filtro: String): TStrings;
var
SR : TSearchRec;
I : integer;
begin
Result := TStringList.create;
I := FindFirst(Caminho+Filtro, faAnyFile, SR);
while I = 0 do
begin
if (SR.Attr and faDirectory) <> faDirectory then
Result.Add(SR.Name);
I := FindNext(SR);
end;
end;Use da seguinte maneira:
procedure TForm1.BitBtn1Click(Sender: TObject); begin CreateThumbs(´D:\Nosredna\Meus documentos\Minhas imagens´,50,ScrollBox1); end;
Aqui funcionou perfeitamaente!!
Teste aew, abraços :wink:
Gostei + 0
08/05/2007
Marcos.gandin
Vou testar aqui...
Muito obrigado mesmo meu amigo!!!
Att.
Gostei + 0
08/05/2007
Marcos.gandin
Eu preciso declarar alguma coisa no Uses ?
Gostei + 0
08/05/2007
Aloizio Castro
Para usar .JPG, declare Jpeg;
Para usar o RightStr declare StrUtils.
Gostei + 0
08/05/2007
Marcos.gandin
Agora funcionou...mas abusando um pouco mais da sua boa vontade, será que tem como quando eu der um duplo-clique na foto abrir ela no seu tamanho original ou então num tamanho pré-determinado em um outro Form ?
Aceito sugestões...
Gostei + 0
09/05/2007
Titanius
[]s
Gostei + 0
09/05/2007
Marcos.gandin
É que eu já consegui fazer os thumbnails com o exemplo que o Adriano me passou, o que eu preciso agora é só fazer com que a foto fique do tamanho original.
Aonde eu consigo essa bilioteca?
Att.
Gostei + 0
09/05/2007
Titanius
Seguinte, ela te mostra o tumb.. mas a parte do tamanho original não, mas isso você mesmo pode fazer, com um Form, e um TImage... dando duplo clique, abre este form mostrando esta imagem...
[]s
Gostei + 0
09/05/2007
Marcos.gandin
Na verdade eu não tinha pensando nessa possibilidade...mas como eu vou saber qual foto vai abrir uma vez que vou colocar o código no evento OnDblClick do componente ScrollBox ?
Att.
Gostei + 0
09/05/2007
Titanius
Bem, no tal componente do JEDI, você tem condicoes de saber qual o arquivo está selecionado, agora como você fez, eu não sei.. você poderá verificar onde foi clicado, e se tem alguma imagem, pra aih descobrir o caminho dela pra exibir... mas aconselho a voce a dar uma olhada neste componente... :wink:
[]s
Gostei + 0
09/05/2007
Marcos.gandin
Essa biblioteca Jedi é Free ?
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)