1. Daniel Vivier
  2. PowerBuilder
  3. Monday, 18 November 2019 01:03 AM UTC

One thing that one of our applications needs is a scanned signature of an officer of the organization using our program, for putting onto the tax receipts it generates. We have specific requirements for that - it has to be exactly 166 x 39 pixels, or any exact multiple of that size.

Not all of the users of our software have the expertise to do the minimal image editing to crop a scanned signature file to that size, and we really don't see it as our job to do it for them! So I'm thinking about whether we could include some functionality in the program to allow them to fairly easily do it.

What I'm imagining is something that allows them to select and display and image file, zoom it an scroll through it if necessary, and use a rectangle that we draw above it, with the 166 x 39 pixel dimensions, to specify the part they want to crop out, and have it save the cropped file with a new name. They would also have to be able to zoom that cropping definition rectangle to multiples of its size if they wanted or needed to crop a larger section. 

Can anyone suggest what sort of external tools or APIs we would need to add to be able to achieve that sort of thing? I suspect most of it can be done up to the point where the cropping is done, just by some careful PowerScript programming. 

One other thing that I can imagine might be needed (particularly for a 2nd image file that the application needs, for the user organization's logo) is extending an existing image file with white space one one side or another. The logo has to be 150 x 60 pixels, or a multiple of that, and if the user's existing logo file is for instance square, it would obviously have to be extended. So that's another thing that I expect would need help from an external API of some sort.

Suggestions? If the suggestion is for a commercial product, it would have to have a reasonable price, royalty-free distribution, and not add too many MB to the since of our installer.

Thanks.

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 18 November 2019 18:00 PM UTC
  2. PowerBuilder
  3. # 1

Hi Dan;

   As Michael suggests ... have a look at the InkEdit control for that. I have used that control in many apps to capture signatures.

   You also have the Ink Picture control as well in the DataWindow Painter plus the Table Blob feature as well. In the DWO when you use the InkPicture Control you can map one DB Column for the Ink Data and another blob column for the Ink Picture. The picture could be a form and the ink data the signature.

   The DWO also has on other "Kool" feature for this is the .. the TableBlob. A feature added in the PB 12.5 time frame. I have used that many times as well for various imaging Apps and signatures as well.

  Food for thought.

HTH

Regards ... Chris

Comment
  1. Miguel Leeuwe
  2. Monday, 18 November 2019 23:10 PM UTC
Hi Chris, but ... how to scale / resize with an inkpicture control / column? I mean, there's lots of stuff out there done in C# and you could communicate with C# DLL, but ... maybe a third party control / activex would save time in the end? I mean there's this kind of 'moire' blurry effects and things which might make it more complicated.

Do you know of any way to resize / scale, etc. using an InkEdit. (in 2009 we used a Kodac ocx which came with windows xp or 95, but no longer is freely available).
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 19 November 2019 15:40 PM UTC
Hi Miguel;

That is why in my last three PB & PowerServer web applications before I joined Appeon, I used the DWO's Ink Edit control. Then all you need to do is set the DWO's Zoom factor and "volia!", any size / scale your users need including the Ink Image. ;-)

DC.Modify("DataWindow.Zoom='200'") // for example

Food for thought;

Regards ... Chris
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 19 November 2019 15:42 PM UTC
PS: For actual Image Editing, Scaling, Cropping, Conversion, Rotation, etc ... I used the free open source "ImageMagick" product to do that. Called from my PB & PS Apps. ;-)
  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Tuesday, 19 November 2019 05:17 AM UTC
  2. PowerBuilder
  3. # 2

There's no easy way for me to export the window (we have quite a few inherited visual user objects on it and it's an inherited response window), but here are the scripts for the functions we used.

ole_1 is the Image Viewer control that allows image manipulation
ole_2 is the cropped image that will be saved
int sel_width & sel_height are the target dimensions of the image to save

Contrast slider (horizontal), min 0, max 255 (code is nearly identical to brightness since the image is reset to default prior to applying new contrast)
moved event
st_contrast.text = string(scrollpos - 127)

ole_1.setredraw(false)
ole_1.object.resetdefaultimage(false)
// always do contrast first
ole_1.object.contrast(255 - scrollpos)

integer brightness
brightness = hsb_brightness.position - 255
ole_1.object.brightness(brightness, brightness, brightness)
ole_1.setredraw(true)

 

Brightness slider (horizontal), min 0, max 255, default 127 (code is nearly identical to contrast since the image is reset to default prior to applying new brightness)
moved event
st_brightness.text = string(scrollpos - 255)

ole_1.setredraw(false)
ole_1.object.resetdefaultimage(false)
// always do contrast first
ole_1.object.contrast(255 - hsb_contrast.position)

integer brightness
brightness = scrollpos - 255
ole_1.object.brightness(brightness, brightness, brightness)
ole_1.setredraw(true)

 

Zoom slider, min=10, max=200, default=100
moved event

ole_1.object.view = 8
ole_1.object.viewsize = scrollpos
ddlb_1.text = string(scrollpos) + "%"

DDLB for zoom, items={Auto, 10%, 25, 33, 50, 66, 75, 100, 125, 150, 175, 200%}
selectionchanged event
string s

int h, v

h = ole_1.object.GetHorzScrollBarPos()
v = ole_1.object.GetVertScrollBarPos()

h = ole_1.object.FileHeight
v = ole_1.object.FileWidth

if this.text = "Auto" then
ole_1.object.View = 10
return
end if

int newsize
s = this.text

if right(s,1) = "%" then s = left(s, len(s)-1)
newsize = long(s)
hsb_1.position = newsize

ole_1.object.view = 8
ole_1.object.viewsize = newsize



Image Open button
integer li_rtn

li_rtn = GetFileOpenName("Select Picture File", &
+ is_FullName, is_FileName, "JPG,BMP,GIF,TGA,PNG", &
"All Image Files (*.jpg;*.bmp;*.gif;*.tga;*.png),*.bmp;*.jpg;*.gif;*.tga;*.png," + &
"Picture Files (JPG),*.jpg,Picture Files (BMP),*.bmp,Picture Files (GIF),*.gif,Picture Files (TGA),*.tga,Picture Files (PNG),*.png")
IF ISNULL(LI_RTN) THEN RETURN
IF li_rtn = 1 THEN
// this.picturename = is_FullName
ole_1.object.filename = is_FullName
ole_1.object.backupcurrentimage()
else
// this.picturename = ""
ole_1.object.filename = ""
is_fullname = ""
is_filename = ""
end if

Crop & Preview button
long ll_top, ll_left

boolean b_rtn

ll_left = ole_1.object.GetHorzScrollBarPos()
ll_top = ole_1.object.GetVertScrollBarPos()
ole_1.object.ClearSelectionRect()

ole_1.object.DrawSelectionRect(ll_left, ll_top, sel_width, sel_height)
b_rtn = ole_1.object.Crop2Clipboard()
ole_1.object.ClearSelectionRect()

ole_2.SetRedraw(False)
b_rtn = ole_2.object.PasteFromClipboard()
ole_2.object.View = 12
ole_2.SetRedraw(True)
ole_2.object.redraw()

cb_ok.enabled = true

 

There are also buttons for pasting the image from clipboard, and rotate 90, they're single object functions (literally ole calls to "pastefromclipboard" and "rotate90").

Hope this helps,

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Monday, 18 November 2019 05:51 AM UTC
  2. PowerBuilder
  3. # 3

Hi Dan, have you tried to use an InkEdit control to capture and later reuse such signature?

Comment
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Monday, 18 November 2019 11:55 AM UTC
  2. PowerBuilder
  3. # 4

Thanks, Michael. That's an interesting idea that I had not considered, but I expect most users would be unhappy with a signature they had to do with their mouse. And it doesn't address the issue of editing the logo, which would need pretty much the same image editing capabilities as I thought I would need for the signature.

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Monday, 18 November 2019 14:35 PM UTC
  2. PowerBuilder
  3. # 5

We've been using Image Viewer CP SDK ActiveX 32/64bit. I created a response window to acquire an image from file, and allow zoom/scale so the user can center the image and snip/save to new filename. Width/height of image is set by the size of the control so the user doesn't have to remember diff sizes for diff image uses.

 

Comment
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Monday, 18 November 2019 14:48 PM UTC
  2. PowerBuilder
  3. # 6

That sounds really good Brad. Any chance you would be willing to share the code for the window?

Comment
There are no comments made yet.
Marco Cimaroli Accepted Answer Pending Moderation
  1. Tuesday, 19 November 2019 09:48 AM UTC
  2. PowerBuilder
  3. # 7

Hi all,

i am using two Wacom tablets : Bamboo and STU-300 (this is better than the first) and ImageMagick dll to resize/modify the signature image captured.

 

Marco

Comment
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Tuesday, 19 November 2019 11:28 AM UTC
  2. PowerBuilder
  3. # 8

I need to be clear that my goal isn't to capture signatures. This if for an official charitable organization's signature, to be used on all of the tax receipts they send to donors. They are going to want it to be a good one, not some scrawl with a mouse, and they won't have tablets - our software is only for Windows PCs. Our requirements are all about taking existing image files (a scanned good signature and/or logo file) and extending if necessary then cropping into set sizes that our software requires.

Comment
There are no comments made yet.
Daniel Vivier Accepted Answer Pending Moderation
  1. Tuesday, 19 November 2019 11:30 AM UTC
  2. PowerBuilder
  3. # 9

Thanks so much, Brad, we will work with this once we get some time for this project!

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.