0
I have a question about uploading images to Delphi. My images have an average size of 47kb, when I display them on Listview application comes to practically lock by the time of the reply.
The images are stored directly in the database with the type predefined blob.
My question is the following, the shipment delay is related with the way I am bringing the data or is a problem of Listview?
What’s the best way to make that shipment? Is that if I store the images in a folder on the server and display them through the URL I will have a better performance?
Follow the excerpt of the code that I read and I read it to Listview:
{$REGION 'Lista Produto'}
TThread.CreateAnonymousThread(
procedure()
begin
TThread.Synchronize(TThread.CurrentThread,
procedure()
begin
dm.UniQuery1.sql.text := 'SELECT pro_id, pro_ds, pro_img, pro_preco '+
'FROM produto WHERE '+
' pro_ds like '+q('%'+edDescricao.Text+'%')+
' AND pro_fabricante_id like '+q(IfThen((edFabricante.Text<>''),auxFabricante,'%'))+
' AND pro_secao like '+q(IfThen((edSecao.Text<>''),auxSecao,'%'))+
' AND pro_merc_id like '+q(IfThen((edMercado.Text<>''),auxMercado,'%'))+
' ORDER BY pro_id DESC';
dm.UniQuery1.Open;
try
ListView1.BeginUpdate;
ListView1.Items.Clear;
S := TMemoryStream.Create();
while not dm.UniQuery1.Eof do
begin
LItem := ListView1.Items.add;
LItem.Text := dm.UniQuery1.FieldByName('pro_ds').AsString;
LItem.Data[TMultiDetailAppearanceNames.Detail1] := dm.UniQuery1.FieldByName('pro_ds').AsString;
LItem.Data[TMultiDetailAppearanceNames.Detail2] := 'R$ '+
FormatFloat('###,###0.00', dm.UniQuery1.FieldByName('pro_preco').AsCurrency);
TblobField(dm.UniQuery1.FieldByName('pro_img')).SaveToStream(S);
s.Position := 0;
imgAux.Bitmap.LoadFromStream(S);
LItem.Bitmap := imgAux.Bitmap;
dm.UniQuery1.Next;
end;
Application.ProcessMessages;
ListView1.EndUpdate;
except
on E: Exception do
ShowMessage('Erro: ' + E.Message);
end;
Application.ProcessMessages;
end);
TThread.Synchronize(TThread.CurrentThread,
procedure()
begin
end);
end).Start;
{$ENDREGION}
It’s likely to be a storage facility, but there may be other problems, I recommend you post the code so we can detect the fault. I did not negatively friend, but who negatived was probably the reason for the lack of code in the question, which is totally justifiable, so put something so that we can understand the problem and it will be very likely to remove the downvote :)
– Guilherme Nascimento
How many such records bring in this SQL, try searching 50 by 50, work with memory caching with Firedac, for example, when you run this process, show only the first 50 or less, because in the application is only a tool for quick access, so you don’t have to show a lot of content.
– Jefferson Rudolf