Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-02-2014
mordaz mordaz is offline
Miembro
 
Registrado: mar 2008
Posts: 32
Poder: 0
mordaz Va por buen camino
Smile Digital Persona SDK en C++ Builder

Buenos dias,

Estoy tratando de traducir el código de ejemplo del SDK del lector biometrico Digital Persona de un ejemplo de Delphi a C++ Builder, pero no logro hacerlo funcionar correctamente.

El código original es el siguiente:

Código Delphi [-]

procedure TForm1.SaveTemplate();
 var
outFile : File of byte;
vrnt: Variant;
vtByteBuf : PByteArray;
aryLow: integer;
aryHigh : integer;
rawDataSize: integer;
loopIndex : integer;
numWritten : integer;
bt : byte;
iTemplate : DPFPShrXLib_TLB.IDPFPTemplateDisp;
begin

try
if SaveDialog.Execute then
      begin
iTemplate := DPFPEnrollment.Template as DPFPShrXLib_TLB.IDPFPTemplateDisp;
vrnt:=iTemplate.Serialize;  //raw data is now stored in this variant

        //Now that you have the variant, try to get raw byte array
        //We are assuming here that you cannot save a variant directly to database field
        //That you need a byte array before saving the data to the database.
        
        aryLow:=VarArrayLowBound(vrnt,1);
        aryHigh:=varArrayHighBound(vrnt,1);
        aryHigh:=aryHigh-aryLow;

        vtByteBuf:=VarArrayLock(vrnt);  //lock down the array
        AssignFile(outFile,saveDialog.FileName);
        Rewrite(outFile);
        for loopIndex := 0 to aryHigh  do
        begin
               //fpData[loopIndex]:=vtByteBuf[loopIndex];
               //bt:=fpData[loopIndex];
               Write(outFile,vtByteBuf[loopIndex]);  //Save directly to file here
        end;
        VarArrayUnlock(vrnt);
      end;
except
on E: Exception do showmessage('Trouble saving data');
end;
        CloseFile(outFile);


end;

Mi codigo en C++ Builder es el siguiente

Código:
void __fastcall TForm1::btnSaveClick(TObject *Sender)
{
  //Guardando la muestra
  OleVariant Ovt;
  IDispatch &pSample=static_cast<IDispatch&>(*DPFPEnrollment->Template);
  IDPFPSample &Muestra=static_cast<IDPFPSample&>(pSample);
  Muestra.Serialize(Ovt);

  //Guardando en archivo
  int aryLow;
  int aryHigh;
  Variant vrnt;
  vrnt=reinterpret_cast <Variant&> (Ovt);
  aryLow=VarArrayLowBound(vrnt,1);
  aryHigh=VarArrayHighBound(vrnt,1);
  aryHigh=aryHigh-aryLow;
  PByteArray vtByteBuf=(PByteArray)VarArrayLock(vrnt);

  ofstream myfile;
  myfile.open ("muestra.bin", ios::out | ios::app | ios::binary);
  for (int loopIndex=0;loopIndex<=aryHigh;loopIndex++){
     myfile<<vtByteBuf[loopIndex];
  }
  VarArrayUnlock(vrnt);
  myfile.close();
}
El código me genera correctamente el archivo "muestra.bin" pero al compararlo en tamaño con uno generado con Delphi existe una diferencia en tamaño considerable. Lo que me hace suponer que no estoy guardando los datos correctamente.

Gracias por su apoyo.

Última edición por Casimiro Notevi fecha: 08-02-2014 a las 10:38:10.
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
Integrar Lector de Huellas [u.are.u 4000b] Digital Persona martini002 Varios 5 26-02-2014 20:42:42
¡Cuidado!, esta persona te lee la mente. Casimiro Notevi La Taberna 1 25-09-2012 15:40:37
Buscando a una persona de Bogotá Al González La Taberna 8 20-02-2009 20:57:26
abogado y una buena persona? marcoszorrilla Humor 1 17-01-2007 02:01:22
Calcular la edad execta de una persona Jorge Taveras SQL 2 13-02-2005 05:25:30


La franja horaria es GMT +2. Ahora son las 16:18:40.


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