Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 07-02-2012
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Poder: 18
cesarsoftware Va por buen camino
Entendido escafandrada

Pero al final tienes que crear un stream para pasarle la imagen, es decir solo nos ahorramos el componente TPng pero se "complica" un poco usando las GDI (que tengo que estudiarlas a fondo, gracias por el ejemplo). La funcion "PintaPantalla" con componentes tarda entre 64 y 78 ms en realizar la operacion en casi cualquier PC.
Es las pruebas que he realizado (por cierto que he "cargado" los componentes Indy de la parte del servidor y los e reemplazado por socket, ya sabes bind, linten, accept y thread, luego los sustituyo en el cliente) la eficiencia es similar. Donde mas me preocupa la eficiencia es la copia de zonas de memoria.

Ahora tengo un "RxBuffer: array[0..65535] of ansichar;" en el servidor que lo recoje de "RxLen := recv(nSocket, RxBuffer, 65536, 0);" y veras que tengo un bucle for para copiar el contenido, ahi si creo que estoy fallando en rendimiento. No veo la funcion que permite esa copia de memoria tipo strcopy etc ¿sabes tu cual es?
Bueno en realizad tengo una zona donde recibo del socket que "RxBuffer" y lo copio con "for" al onRecibido y este "ServidorRecibido" incrementa el buffer para generar la imagen. Tambien seria genial saber cual es la funcion que copia, o mejor dicho, incrementa un buffer con el contenido de otro.

Gracias por seguir el tema (curiosa las funciones Lock/UnLock del bitmap, jejeje)

Código Delphi [-]
var
    SCRBuffer: array of ansichar;

procedure TFormPantalla.ServidorRecibido(Sender: TObject);
var
  i, rec, p: integer;
begin
  p := SCRrec; // posicion anterior
  rec := ServidorSCR.RxLen;
  Inc(SCRRec, rec);
  SetLength(SCRbuffer, SCRRec);
  for i := 0 to rec - 1 do
    SCRBuffer[p + i] := ServidorSCR.RxBuffer[i];
  if (GetTickCount() - tOutLoad) > 5000 then
  begin
    Application.MessageBox('TimeOut > 5000 ms', 'Atención', MB_ICONWARNING + MB_OK);
    Imagen.Picture := nil;
    Imagen.Refresh;
    SCRSize := 0;
    SCRRec := 0;
    SetLength(SCRBuffer, 0);
    GaugeLoad.Progress := 0;
    GaugeLoad.Refresh;
    tOutLoad := GetTickCount();
    Exit;
  end;
  GaugeLoad.Progress := Length(SCRBuffer);
  GaugeLoad.Refresh;
  tOutLoad := GetTickCount();
  if SCRrec = SCRSize then
  begin
    PintaPantalla();
    SCRSize := 0;
    SCRRec := 0;
    SetLength(SCRBuffer, 0);
    tFinLoad := GetTickCount();
    STtimeLoad.Caption := IntToStr(tFinLoad - tIniLoad) + ' ms.';
    Pidepantalla();
  end;
end;

procedure TFormPantalla.ProcesaPantalla(recibido: string);
begin
  SCRSize := StrToIntDef(Copy(recibido, 6, Length(recibido) - 6), 0);
  GaugeLoad.MaxValue := SCRSize;
  GaugeLoad.Refresh;
end;

procedure TFormPantalla.PintaPantalla();
var
  LStream: TMemoryStream;
  LPngImage: TPngImage;
begin
  LStream := TMemoryStream.Create;
  LPngImage := TPngImage.Create;
  try
    LStream.Write(SCRBuffer[0], SCRSize);
    LStream.Position := 0;
    LPngImage.Canvas.Lock;
    LPngImage.LoadFromStream(LStream);
    LPngImage.Canvas.Unlock;
    Imagen.Picture.Assign(LPngImage);
    Imagen.Refresh;
  finally
    LStream.Free;
    LPngImage.Free;
  end;
end;

procedure TFormPantalla.PidePantalla;
var
  msg: ansistring;
begin
  tIniLoad := GetTickCount();
  tOutLoad := tIniLoad;
  msg := '[OKSCR]' + #13 + #10;
  ClienteCMD.Envia(AnsiString(msg));
end;
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
liberar memoria Celta Varios 5 12-12-2010 18:07:17
Liberar memoria Sick boy Varios 6 02-07-2005 10:11:29
problema tonto gatsu PHP 2 25-04-2005 21:41:21
Liberar Memoria JoseQ Varios 6 16-07-2004 18:49:21
Liberar Memoria JODELSA Varios 4 13-05-2003 17:39:05


La franja horaria es GMT +2. Ahora son las 20:31:02.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi