VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 12345678[9]10 ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 08:26:23 11/24/00 Fri
Author: Jorge Neudorfer
Subject: Thumnails of directory

Hello to all, I do a consultation to them. I am using the following program to create the thumnail of pictures of a directory but when having but of 24 imagenes in the directory gives error me.

(CreateDibSection Failed) raise EEnvisionError.Create('CreateDibSection failed');


This good my program?
What optimization recommends to me?

Excuse if my English is not very good
Greetings

Jorge Neudorfer
Asuncion - Paraguay


procedure TFrmFotos.btnBuscarClick(Sender: TObject);
var
x:Integer;
Paht_Var :String;
Numero :Integer;
Form : TResizeForm;
Transform : TResizeTransform;
ImageFormat : TImageFormat;
FUndoGraphic : TDibGraphic;
Alto:Integer;
Ancho:Integer;
Alto_Temp:REAL;
Ancho_Temp:Double;
Alto2:Integer;
Ancho2:Integer;
aLL: sTRING;
LongiDir :Integer;
SoloDir : String;
indi:integer;
Letra,BuscaDir,HoraTexto : String;

begin

Numero := 2;
TblFotos.DisableControls;
for x:= 0 to Fl1.Items.Count -1 do
begin
Paht_Var := Dl1.Directory + '\'+Fl1.Items.Strings[x];

TblFotos.Append;
QryUltCod.Close;
QryUltCod.Open;
TblFotos.FieldByName('Cod_Foto').AsInteger := QryUltCod.fieldbyname('UltCod').AsInteger +1 ;

//VER NOMBRE DE LA CARPETA Y BUSCAR EN LAS SECCIONES
Buscadir :='';
Letra := '';
SoloDir := '';
LongiDir := Length(Dl1.Directory);
SoloDir := Dl1.Directory;
indi := LongiDir;
Letra := UpCase(SoloDir[indi]);
while (Letra <> '\') and (indi <= Longidir) do
begin
BuscaDir := Letra + BuscaDir;
indi := indi - 1;
Letra := Upcase(SoloDir[indi]);
end;

try
QrySeccion.Close;
except
ShowMessage('Error al cerrar la consulta');
end;

QrySeccion.MacroByName('Nom_Sec').AsString := chr(39) + BuscaDir + chr(39);

try
QrySeccion.Open;
except
ShowMessage('Error al abrir la consulta');
end;
//FIN VER NOMBRE

//PONER CODIGO EN LA TABLA
TblFotos.FieldByName('Cod_Seccion').AsInteger := QrySeccion.FieldByName('Cod_Seccion').AsInteger;


TblFotos.FieldByName('Titulo').AsString := 'Foto ' + IntToStr(QryUltCod.fieldbyname('UltCod').AsInteger +1);
TblFotos.FieldByName('Path').AsString := '\Db2srv\Fotos\Thum\'+Fl1.Items.Strings[x];//Paht_Var;
TblFotos.FieldByName('Path_Or').AsString := '\Db2srv\Fotos\Original\'+Fl1.Items.Strings[x];//Paht_Var;
TblFotos.FieldByName('Tema').AsString := 'Introduzca un tema para la foto';
TblFotos.FieldByName('Descripcion').AsString := 'Introduzca una descripción para la foto';
TblFotos.FieldByName('Comentario').AsString := 'Introduzca un comentario para la foto';

TblFotos.FieldByName('Fecha').AsDateTime := Date;

HoraTexto := Copy(TimeToStr(Time),1,2)+Copy(TimeToStr(Time),4,2);
TblFotos.FieldByName('Hora').AsString := HoraTexto;


CopyFile(Pchar(Fl1.Items.Strings[x]),Pchar('\Db2srv\Fotos\Original\'+ Fl1.Items.Strings[x]),false);
Achicador.LoadFromFile(Paht_Var, 1);
// Achicador.Width := 80;
// Achicador.Height := 80;

{FUndoGraphic.Assign(Achicador.Graphic);
Transform.ApplyOnDest(FUndoGraphic, Achicador.Graphic);
Achicador.Redraw(true);}




Transform := TResizeTransform.Create;
Form := TResizeForm.Create(nil);
FUndoGraphic := TDibGraphic.Create;
try
Form.WidthFld.Text := IntToStr(Achicador.Graphic.Width);
Form.HeightFld.Text := IntToStr(Achicador.Graphic.Height);
//ShowMessage('Ancho : '+ IntToStr(Achicador.Graphic.Width));
//ShowMessage('Alto : '+IntToStr(Achicador.Graphic.Height));
Alto := 0;
Ancho := 0;
if Achicador.Graphic.Width > Achicador.Graphic.Height then
begin
Alto := 90;
Ancho := 125;
TblFotos.FieldByName('Forma').AsString := 'H';
end;

if Achicador.Graphic.Width < Achicador.Graphic.Height then
begin
Alto := 90;
Ancho := 80;
TblFotos.FieldByName('Forma').AsString := 'V'
end;

if Achicador.Graphic.Width = Achicador.Graphic.Height then
begin
Alto := 90;
Ancho := 90;
TblFotos.FieldByName('Forma').AsString := 'C';
end;

// Alto := Achicador.Graphic.Height - Trunc((Achicador.Graphic.Height*60)/100);
// Ancho :=Achicador.Graphic.Width - Trunc((Achicador.Graphic.Width*60)/100);
// if alto > ancho then
// else


Form.DestFormatCB.ItemIndex := Integer(Achicador.Graphic.ImageFormat);

// if Form.ShowModal <> mrOk then
// Abort;

Transform.Interpolated := Form.InterpolatedCB.Checked;

if Transform.Interpolated then
begin
Transform.Filter := TInterpolationFilter(Form.FilterCB.ItemIndex);

ImageFormat := TImageFormat(Form.DestFormatCB.ItemIndex);

if ImageFormat <> Achicador.Graphic.ImageFormat then
begin
Transform.OverrideDestFormat := True;
Transform.DestFormat := ImageFormat;
end;
end;

Transform.Width := Ancho;//StrToInt(Form.WidthFld.Text);
Transform.Height := Alto;//StrToInt(Form.HeightFld.Text);

FUndoGraphic.Assign(Achicador.Graphic);

// Transform.OnProgress := Self.OnProgress;
Transform.ApplyOnDest(FUndoGraphic, Achicador.Graphic);
Achicador.SaveToFile('\Db2srv\Fotos\Thum\'+Fl1.Items.Strings[x]);
finally
Form.Free;
Transform.Free;

TblFotos.Post;

end;

// FDirty := True;
Achicador.Redraw(True);


end;
ShowMessage('Proceso finalizado' + #13 + 'Cantidad de imagenes agregadas: '+ IntToStr(x));
TblFotos.EnableControls;
end;

[ Next Thread | Previous Thread | Next Message | Previous Message ]


Replies:


[ Contact Forum Admin ]


Forum timezone: GMT-5
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.