PDA

Ver la Versión Completa : como capturar una imagen de codigo rq y fuscarlo en una bd


cl2raul
01-10-2015, 17:16:10
Hola a todos estoy tratando de capturar usando la camara del movil codigos qr o de barras ya hechos, estos pertenecen a una base de datos montada en MySQL, el problema es q no tengo la menor idea... alguien sabe de componentes free que me tradusca el codigo??

aposi
01-10-2015, 17:54:53
Hola,

descarga en el telefono el programa Barcode Scanner de zxing

en el Create del form pon este codigo:


procedure TForm1.FormCreate(Sender: TObject);
var
aFMXApplicationEventService: IFMXApplicationEventService;
begin
FMonitorClipboard := False;
if not TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, IInterface(ClipService)) then
ClipService := nil;
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
begin
aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent);
end
else
begin
Log.d('Application Event Service is not supported.');
end;

end;





Crea estas dos funciones:


unction TForm1.GetBarcodeValue: Boolean;
var
value: String;
begin
Result := False;
FMonitorClipboard := False;
if (ClipService.GetClipboard.ToString <> 'nil') then
begin
Edit1.Text := ClipService.GetClipboard.ToString;
ClipService.SetClipboard(FPreservedClipboardValue);
Result := True;
end;
end;

function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;

begin
Result := False;
if FMonitorClipboard and (AAppEvent = TApplicationEvent.BecameActive) then
begin
Result := GetBarcodeValue;
end;

end;






Crea un boton y que ejecute este codigo:



procedure TForm1.SpeedButton1Click(Sender: TObject);
var
intent: JIntent;
begin
if Assigned(ClipService) then
begin
FPreservedClipboardValue := ClipService.GetClipboard;
FMonitorClipboard := True;
ClipService.SetClipboard('nil');
intent := TJIntent.Create;
intent.setAction(StringToJString('com.google.zxing.client.android.SCAN'));

SharedActivity.startActivityForResult(intent, 0);
end;
end;

cl2raul
02-10-2015, 02:00:53
gracias aposi lo probare, que gratificante es ver cuanta ayuda se encuentra en este foro y q viva delphi....

cl2raul
02-10-2015, 20:01:26
mira, me da los siguientes problemas en:
function HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;

marca como 'Undeclared identifier', creo que falta algo en el uses...
TApplicationEvent
FMonitorClipboard
ClipService
JIntent
TPlatformServices

por favor ayuda