0

recently my company bought a Wacom STU-530 signature pad and I've to realize a prgram that acquire the client signature from it and create a pdf with the signature. I use FastReport for realizing the PDF, but I need to acquire the signature from the wacom tablet. With the sdk I realized this code:

procedure TfrmMain.btnFirmaClick(Sender: TObject);
var
  objFirma: SigObj;
  ctlFirma: TSigCtl;
  picFirma: TPicture;
  res: CaptureResult;
begin
  picFirma := TPicture.Create;
  ctlFirma := TSigCtl.Create(Self);
  res := ctlFirma.Capture('Firmare per accettazione',
    'Formazione del personale in affiancamento');
  case res of
    CaptureOK: begin
      objFirma := SigObj(ctlFirma.Signature);
      SetOlePicture(picFirma, objFirma.Picture(300, 300, 'image/bmp', 0.5, $000000,
        $ffffff, -1.0, -1.0, RenderOutputPicture or RenderColor32BPP or
        RenderEncodeData));
      picFirma.SaveToFile('firma.bmp');
    end;
  end;
  ctlFirma.Free;
  picFirma.Free;
end;

The SigObj has a method that return a IPictureDisp and I need to convert it into a TImage so I've used the SetOlePicture, but When I save the Image it is unreadable. If I try to save the picture with

picFirma.bitmap.SaveToFile('firma.bmp')  

the resulting bitmap is void. What is wrong in my code?

Eros
  • 337
  • 1
  • 22
  • 2
    I think you need to ask the vendor about this. They should provide you an example of how to accomplish what you want. – RBA May 26 '16 at 09:58
  • The problem is not the Wacom SDK, but the IPictureDisp it return. The SetOlePicture Should connect the IPictureDisp object to the TPicture object, but when I save the image on a file it is unreadable or empty. – Eros May 26 '16 at 14:13
  • @Eros RBK may be right; Indeed, not all libraries do the correct iPictureDisp implementation, even Microsoft themselves do not implement it correctly - see http://stackoverflow.com/a/480350/976391 Ask the vendor, try to get sample code from them – Arioch 'The May 26 '16 at 15:14
  • MSDN about IPictureDisp says two interesting things: 1) it has `Type` property of PICTYPE type which can be `bitmap` or anything else including `non-initialized` type-stub : https://msdn.microsoft.com/ru-ru/library/windows/desktop/ms687195.aspx and 2) typically objects with IPictureDisp interface also do implement IPicture interface that has a native `SaveToFile` method https://msdn.microsoft.com/ru-ru/library/windows/desktop/ms694504.aspx – Arioch 'The May 26 '16 at 15:18
  • if your Delphi still comes with sources for Vcl.AxCtrls unit try to step into and to debug internals of `SetOlePicture` and that might hint you which assumption went wrong – Arioch 'The May 26 '16 at 15:21

2 Answers2

0

According to Signature Components API delivered with Signature SDK to get the signature in bitmap you should use RenderBitmap method.

RenderBitmap( outputFilename, dimensionX, dimensionY, mimeType, inkWidth, nkColor, backgroundColor, paddingX, paddingY, flags)
Renders an image of the signature, creating an image file or returning the binary data. Optionally encodes the SigObj data in the generated image using steganographic techniques.

    objFirma:= SigObj(ctlFirma.Signature);
    objFirma.RenderBitmap('firma.bmp', 300, 300, 'image/bmp', 0.5, $000000,
    $ffffff, -1.0, -1.0, RenderOutputFilename or RenderColor32BPP or RenderEncodeData);
0

In the current version of Wacom signature SDK 4.5.6 your code works fine.

Moje Meno
  • 21
  • 4
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – Ranjith Sep 07 '21 at 12:17