SetSignImageEx

Declaration

Delphi

procedure SetSignImageEx(Assign: Boolean; Encoding: Integer; Width, Height: Integer; Image: PByte; Size: Cardinal);

C/C++

SOPAD_API void SOPAD_setSignImageEx(int bAssign, int nEncoding, int nWidth, int nHeight, const void* pImage, int nSize);

ActiveX

HRESULT SetSignImageEx([in] VARIANT_BOOL Assign, [in] long Encoding, [in] long Width, [in] long Height, [in] VARIANT Image);

Description

It's possible to display custom image (for example, part of the document) on the pad's LCD during signing. This function allows to define custom image. Image will be actually drawn on the call of startCapture function.

NOTE: This function only works with signature pads with B/W display. For Signature Pads with colour display please see LCDImage or LCDImageEx, LCDImageExR

Arguments

Assign

Pass a non-zero value to store image, zero value to clear image.

Encoding

Image encoding method

ValueDescription
0Pre-naturaSign compatible. One byte represents one horizontal line of 8 pixels.
1naturaSign compatibe. One byte represents one vertical line of 8 pixels.

 

Width and Height

Size of signature image

LCDImageArrayImage

Single-dimensional array, containing byte values.

Array should have the following format:
Each bit represents one pixel, bit value = 1 means that pixel should be lit, thus one byte determines eight pixels state. The first byte of array corresponds to a line of pixels starting from (0, 0). In a byte bit 0 determines the leftmost or topmost pixel.

Size

Size of binary data block.

Sample-Code

C# Sample
device = new StepOverSignatureDevice();
  
string padsettings = "";
bool foundPad = device.checkConnectedPad("", true, false, true, ref padsettings);
string devicetyp = device.GetDriverString(0);
  
if ((devicetyp == "StepOver naturaSign Pad Mobile") || (devicetyp == "StepOver naturaSign Pad Biometric"))
{
    int w = device.GetDriverLong(20) /* width */;
    int h = device.GetDriverLong(21) /* height */;
  
 // Create Image
  
    Bitmap bmp = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    Graphics gr = Graphics.FromImage(bmp);
    gr.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, w, h));
    gr.DrawString("Hello, World,", new Font("Arial", 16), Brushes.Black, new PointF(10, 10));
    gr.DrawString("This is a Test", new Font("Arial", 16), Brushes.Black, new PointF(10, 50));
  
 // Image to ByteArray
  
    int BufferSize = (int) Math.Ceiling((double) h / 8) * w;
    //  Pad Typ StepOver naturaSign Mobile
    Byte[] bytes = new Byte[BufferSize];
    for (int i = 0; i < h / 8; i++)
    {
     for (int j = 0; j < w; j++)
     {
      byte b = 0;
      for (int k = 0; k < 8; k++)
      {
       b >>= 1;
       if (bmp.GetPixel(j, i * 8 + k).ToArgb() != Color.White.ToArgb())
        b |= 0x80;
      }
      int idx = i * w + j;
      if (idx < BufferSize)
       bytes[idx] = b;
      else
       throw new Exception("Range check error.");
     }
    }
    bmp.Dispose();
 
    device.SetSignImageEx(true, 1, w, h, bytes);
}
  
// remove on Signatur-line by the LCD Pads
/*      
const int DRIVER_OPTION1_TRANSPARENT_DRAW_MODE = 0x00000010;
device.SetDriverLong(0, device.GetDriverLong(0) & ~DRIVER_OPTION1_TRANSPARENT_DRAW_MODE);
*/
  
device.startCapture("", true, true, true, true, ref padsettings);
C++
  //  LCD Pad (Standard, Mobile, Classic or Biometric)
  int w = SigDev.GetDriverLong(DRIVER_LCD_WIDTH);
  int h = SigDev.GetDriverLong(DRIVER_LCD_HEIGHT);

  //prepare the bitmap attributes
  BITMAPINFO bmInfo;
  memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
  bmInfo.bmiHeader.biSize     = sizeof(BITMAPINFOHEADER);
  bmInfo.bmiHeader.biWidth    = w;
  bmInfo.bmiHeader.biHeight   = h;
  bmInfo.bmiHeader.biPlanes   = 1;
  bmInfo.bmiHeader.biBitCount = 24;

  //create a temporary dc in memory.
  HDC pDC   = ::GetDC(0);
  HDC TmpDC = CreateCompatibleDC(pDC);

  //create a new bitmap and select it in the memory dc
  BYTE *pbase;
  HBITMAP TmpBmp = CreateDIBSection(pDC,&bmInfo,DIB_RGB_COLORS,(void**)&pbase,0,0);
  HGDIOBJ TmpObj = SelectObject(TmpDC,TmpBmp);
  HBRUSH hbr = CreateSolidBrush(RGB(255,255,255));
  RECT pos = {0,0,w,h};
  FillRect(TmpDC,&pos,hbr);

  //choose the font
  CFont    m_Font;
  LOGFONT *m_pLF;
  m_pLF = (LOGFONT*) calloc(1,sizeof(LOGFONT));
  wcsncpy_s(m_pLF->lfFaceName,32,_T("Arial Bold"),11);
  m_pLF->lfHeight = 16;
  m_pLF->lfWeight = 0;
  m_pLF->lfItalic = 0;
  m_pLF->lfUnderline = 0;
  HFONT hfont = CreateFontIndirect(m_pLF);
  HGDIOBJ pOldFont;
  if (hfont) 
   pOldFont = SelectObject(TmpDC,hfont);
  else 
   pOldFont = SelectObject(TmpDC,GetStockObject(DEFAULT_GUI_FONT));

  //draw the text 
  SetBkMode(TmpDC,TRANSPARENT); 
  SetTextColor(TmpDC,RGB(0,0,0));
  TextOut(TmpDC,10,10,_T("Hello, World,") ,13); 
  TextOut(TmpDC,10,50,_T("This is a Test"),14); 

  // cleanup 
  SelectObject(TmpDC,pOldFont);
  m_Font.DeleteObject();
  free(m_pLF);

        //  Create the Byte Array of the Image
  int BufferSize = (int) (h / 8) * w;
  unsigned char *bytes = (unsigned char *) malloc(BufferSize);
        for (int i = 0; i < h / 8; i++)
        {
            for (int j = 0; j < w; j++)
            {
                byte b = 0;
                for (int k = 0; k < 8; k++)
                {
                    b >>= 1;
                    if (GetPixel(TmpDC,j, i * 8 + k) != RGB(255,255,255))
                        b |= 0x80;
                }
                int idx = i * w + j;
                if (idx < BufferSize)
                {
                    bytes[idx] = b;
                }
            }
        }

  HRESULT hr;
  VARIANT vrRawData;
  
  VariantInit(&vrRawData);
  
  SAFEARRAY *psarray;
  SAFEARRAYBOUND sabounds[1];
  sabounds[0].lLbound=0;
  sabounds[0].cElements = BufferSize;
  psarray = SafeArrayCreate(VT_UI1, 1, sabounds);
  vrRawData.vt = VT_ARRAY|VT_UI1;
  if(psarray != NULL) 
  {
   vrRawData.parray = psarray;
   long lDimension = 0; 
   for ( long i = 0; i < BufferSize; i++ ) 
   {
    unsigned char dc = bytes[i]; 
    hr = SafeArrayPutElement(vrRawData.parray,&i,&dc);
   }
  }
 
  // upload Image 
  SigDev.SetSignImageEx(true, 1, w, h, vrRawData);
VB.net
' LCD Pad (Standard, Mobile, Classic or Biometric)
Dim w As Integer = AxStepOverSignatureDevice1.GetDriverLong(DRIVER_LCD_WIDTH)
Dim h As Integer = AxStepOverSignatureDevice1.GetDriverLong(DRIVER_LCD_HEIGHT)  
 
'  Create a new Image
Dim bmp As Bitmap = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
Dim gr As Graphics = Graphics.FromImage(bmp)
                
' Add some text to the Image
gr.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, w, h))
gr.DrawString("Hello, World,", new Font("Arial", 16), Brushes.Black, new PointF(10, 10))
gr.DrawString("This is a Test", new Font("Arial", 16), Brushes.Black, new PointF(10, 50))
                
' Create the Byte Array of the Image
Dim BufferSize As Integer = Math.Ceiling(h / 8) * w
Dim bytes(BufferSize) As Byte 
for i as Integer = 0 to  (h / 8)-1 
     for j as Integer = 0 to w-1
         Dim b as Byte = 0
            for  k as Integer = 0 to 7
                 b = b >> 1
                 If (i * 8 + k) < h then
                     if (bmp.GetPixel(j, (i * 8 + k)).ToArgb() <> Color.White.ToArgb()) then
                         b = b or &H80
                     end if
                 end if
            next
                    
	    Dim idx as Integer = i * w + j
            if (idx < BufferSize) then
                bytes(idx) = b
            else
                throw new Exception("Range check error.")
            End if
     Next
Next 
 
bmp.Dispose()
AxStepOverSignatureDevice1.SetSignImageEx(true, 1, w, h, bytes)
 
Delphi
//  LCD Pad (Standard, Mobile, Classic or Biometric)
w := SigDev.GetDriverLong(DRIVER_LCD_WIDTH);
h := SigDev.GetDriverLong(DRIVER_LCD_HEIGHT);
 
//  Create a new Image
bmp              := TBitmap.Create;
bmp.Width        := w;
bmp.Height       := h;
bmp.PixelFormat  := pf24bit;
bmp.Canvas.Brush.Color := clWhite;
bmp.Canvas.FillRect(Rect(0,0,w,h));
 
//  Add some text to the Image
bmp.Canvas.Font.Name    := 'Arial';
bmp.Canvas.Font.Height  := 16;
bmp.Canvas.Font.Color   := clBlack;
bmp.Canvas.TextOut(10,10,'Hello World');
bmp.Canvas.TextOut(10,50,'This is a Test');
 
//  Create the Byte Array of the Image
BufferSize := Integer(Ceil(h / 8) * w);
SetLength(BMPBytes,Buffersize);
for i := 0 to (h shr 3) do
	begin
            for j := 0 to w-1 do
            begin
                b := 0;
                for k := 0 to 7 do
                begin
                    b := b shr 1;
                    if bmp.Canvas.Pixels[j, i * 8 + k] <> clWhite then
                    begin
                        b := b or $80;
                    end;
                end;
                BMPbytes[i * w + j] := b;
        end;
end;
 
bmp.Free;
 
SigDev.SetSignImageEx(true, 1, w, h, BMPbytes);