Ver Mensaje Individual
  #21  
Antiguo 22-03-2012
Avatar de jafera
jafera jafera is offline
Miembro
 
Registrado: may 2007
Ubicación: Llagostera (Girona)
Posts: 582
Reputación: 18
jafera Va por buen camino
Otra duda, en este procedimiento, cambio la anchura y altura de la imagen dependiendo de la posición en el formulario, esto funciona bien es lo que comentaba en el post anterior. Con el añadido de las miniaturas igual esto se puede quitar y basarnos solo en el click en la miniatura para verla, no se si es mejor.

Código Delphi [-]
 
procedure TF_Camions.Fotos_CAfterScroll(DataSet: TDataSet);
var
        jpg:TJpegImage;
        foto:TMemoryStream;
begin
        If FileExists('C:\Bombers_1.0\Temp\Temporal.jpg') then
        DeleteFile ('C:\Bombers_1.0\Temp\Temporal.jpg');
        If Fotos_CFOTO.Value<>'' then
        begin
                Jpg:=TJpegImage.create;
                Foto:=TMemoryStream.create;
                try
                        Fotos_CFOTO.SaveToStream(Foto);
                        Foto.Seek(0,soFromBeginning);
                        Jpg.LoadFromStream(Foto);
                        Jpg.SaveToFile('C:\Bombers_1.0\Temp\Temporal.jpg');
                        if jpg.Width > jpg.Height then
                        begin
                                Image2.Width := 500;
                                Image2.Height := 376;
                                Image2.Picture.Assign(Jpg);
                                Image1.Width := 500;
                                Image1.Height := 376;
                                Image1.Stretch:=False;
                                Image1.Picture.Assign(Jpg);
                        end
                        else
                        begin
                                Image2.Width := 376;
                                Image2.Height:=500;
                                Image2.Picture.Assign(Jpg);
                                Image1.Width := 282;
                                Image1.Height := 376;
                                Image1.Stretch:=True;
                                Image1.Picture.Assign(Jpg);
                        end;
                finally
                        Foto.Free;
                        Jpg.Free;
                end;
        end
        else
        begin
                Image2.Picture.Assign(nil);
                Image1.Picture.Assign(nil);
        end;
end;

Cuando asigno el valor de la tabla FOTO al DBImage de la miniatura, puedo ajustar la medida de la misma dependiendo de si la foto es horizontal o vertical?

He intentado con:

Código Delphi [-]
begin
                TumbN.Close;
                TumbN.CreateDataSet;
                TumbN.Open;
                B:= TBitmap.Create;
                try
                        while not Fotos_C.Eof do
                        begin
                              TumbN.Append;
                              TumbNID.Value:= Fotos_C.FieldByName('ID').Value;
                              JpgToBitmap(Fotos_C.FieldByName('FOTO'), B);
                              TumbNFOTO.Assign(B);
                              TumbN.Post;
                              Fotos_C.Next;
                        end;
                finally
                        B.Free
                end;
                TumbN.Last;
                TumbN.First;
                If TumbN.RecordCount = 0 then
                begin
                        DBCtrlGrid1.Visible:=False;
                end
                else
                begin
                        DBCtrlGrid1.Visible:=True;
                        If (TumbN.RecordCount >= 1) and (TumbN.RecordCount <= 10) then
                        begin
                                DBCtrlGrid1.ColCount:=TumbN.RecordCount;
                        end
                        else
                        begin
                                DBCtrlGrid1.ColCount:=10;
                        end;
                end;
                DBCtrlGrid1.DataSource:= DSTumbN;
                DBImage1.DataField:= 'FOTO';
                If DBImage1.Width > DBImage1.Heigth then
                begin
                        DBImage1.Width:=100;
                        DBImage1.Heigth:=75;
                end
                else
                begin
                        DBImage1.Width:=75;
                        DBImage1.Heigth:=10;
                end;
                DBImage1.Stretch:= True;
        end;

La parte en rojo no funciona, no se si el código está mal colocado o no es la función correcta.

Saludos

Josep
Responder Con Cita