1. CJ Lai
  2. PowerBuilder
  3. Thursday, 20 February 2020 21:05 PM

Hi

I have an InkPicture control which saves the content by the InkPicture_1.Save(lblob_blob, 0, True) call, which generates a blob that's stored in the lblob_blob variable.

Now, is it possible to resize said blob?

If so, please advise how. It'd be greatly appreciated.

CJ

Accepted Answer
CJ Lai Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 15:51 PM
  2. PowerBuilder
  3. # Permalink
2
Votes
Undo

Hi guys,

Thank you all so much for your input. I really appreciate it.

Since a blob can not be resize without first being converted into a picture/image AND use a 3-party tool, I have decided just to limit the size of my InkPicture control so the application will not capture an over-sized signature to begin. Then I'll resize my output MSWord doc too accommodate such picture/image after retrieval.

That's my best approach.

 

CJ

Comment
Thanks for sharing your approach!
  1. Armeen Mazda @Appeon
  2. Thursday, 5 March 2020 17:14 PM
Thanks for sharing.
  1. Michael Kramer
  2. Thursday, 5 March 2020 18:23 PM
Hi CJ ... TIP: I use an InkPicture DataWindow instead of an InkPicture Control. That way, your image can then also become zoomable. ;-)
  1. Chris Pollach @Appeon
  2. Friday, 6 March 2020 17:09 PM
There are no comments made yet.
Juan Jose Marquez Martin Accepted Answer Pending Moderation
  1. Thursday, 28 May 2020 07:39 AM
  2. PowerBuilder
  3. # 1
1
Votes
Undo

I solved a similar question (rotating an InkPicture) reading the information in MSDN for calling Windows APIs

 

https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchblt

 

permits to scale an image, this and many other functions for graphical actions are explained for C++ code, but you can more or less complex translation to PB, the most hard task it's for determine the type of parameters for trespassing to.

 

The website  https://www.topwizprogramming.com/freecode_bitmap.html have free code where you can start to learn how do it this.

 

You must employ an amount of hours, but I think greatful because finally you learn to manage the graphs and you can see that many questions as this can be resolved without external help or products. In my case, third party products are forbidden by the corp to develope and this was the final solution.

 

Unfortunately, I can share the complete code, because I have a confidentiality clause, only can share some ideas to direct your head to the correct direction.

 

A part  of the image rotation code

 

...


CASE POS_ROTATED_RIGHT
lst_PolygonPoint[ 1 ].X = ll_Height
lst_PolygonPoint[ 1 ].Y = 0
lst_PolygonPoint[ 2 ].X = ll_Height
lst_PolygonPoint[ 2 ].Y = ll_Width
lst_PolygonPoint[ 3 ].X = 0
lst_PolygonPoint[ 3 ].Y = 0

END CHOOSE

IF ai_rotation = POS_ROTATED_RIGHT OR ai_rotation = POS_ROTATED_LEFT THEN

ll_Aux = lstr_Info.bmiHeader.biWidth
lstr_Info.bmiHeader.biWidth = lstr_Info.bmiHeader.biHeight / lstr_Info.bmiHeader.biYPelsPerMeter * lstr_Info.bmiHeader.biXPelsPerMeter
lstr_Info.bmiHeader.biHeight = ll_Aux / lstr_Info.bmiHeader.biXPelsPerMeter * lstr_Info.bmiHeader.biYPelsPerMeter

END IF

ll_hDC = CreateCompatibleDC( 0 )
ll_hBitmap = CreateDIBSection( 0, lstr_Info, DIB_RGB_COLORS, 0, 0, 0 )
SelectObject( ll_hDC, ll_hBitmap )

lb_result = PlgBlt( ll_hDC, lst_PolygonPoint, ll_hDCAux, 0, 0, ll_Width, ll_Height, 0, 0, 0 )

IF ai_rotation = POS_ROTATED_RIGHT OR ai_rotation = POS_ROTATED_LEFT THEN

ll_Aux = ll_Width
ll_Width = ll_Height
ll_Height = ll_Aux

END IF

lstr_Info.bmiHeader.biSize = INFO_SIZE

IF GetDIBits( ll_hDC, ll_hBitmap, 0, ll_Height, 0, lstr_Info, DIB_RGB_COLORS ) > 0 THEN

...

 

and a part of the local external function definition

 

...


Private &
Function boolean PlgBlt &
( longPtr hdcDest &
, Ref lpPoint lpPoint[3] &
, longPtr hdcSrc &
, long nXSrc &
, long nYSrc &
, long nWidth &
, long nHeight &
, longptr hbmMask &
, long nXMask &
, long nYMask &
) Library 'gdi32.dll'

...

 

I hope that you can do it easily

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 21 February 2020 23:26 PM
  2. PowerBuilder
  3. # 2
0
Votes
Undo

You can turn your blob into an image then use one of the many online converters that exit:
https://tinyjpg.com/
https://tinypng.com/

and so on.


Olan

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 21 February 2020 16:31 PM
  2. PowerBuilder
  3. # 3
1
Votes
Undo

Hi CJ;

  FYI: I have written many PB  and even PowerServer apps that could perform this processing requirement. The key of course is not the BLOB data type but, the type of datum contained within its data stream.

   Assuming that your blobs are always images of some kind (like I was encountering in my PB/PS apps), the key for image introspection, conversion, resizing, etc was to link outside the PB/PS apps to an external imaging tool. For my image related apps, I mostly have used either "ImageMagick" or "GraphicsMagick" to perform imaging operations. There are many paid 3rd party imaging tools out there for this as well but, they tend to be very expensive. The above aforementioned tools are open source and thus free.

FYI ...

http://www.graphicsmagick.org

https://imagemagick.org/index.php

  For the ImageMagick product, it includes both a command-line interface and an OCX interface as well. I normally use the OCX interface for image "introspection" and then the command-Line interface for image manipulations.  You could use the OCX all the way through but the CL interface has more options (depending on what your App wants to accomplish image wise).

  The GraphicsMagick product is also free and open source. Its actually a "fork" of "ImageMagick" product but just has been "super tuned" for performance. So if your writing a batch PB App that is blasting through 100K+ images all the time - this product is awesome for through-put.  ;-)

Food for thought.  HTH

Regards ... Chris 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 21:17 PM
  2. PowerBuilder
  3. # 4
1
Votes
Undo

If you mean resize the graphics, say from (640 x 400) down to (64 x 40) then
NO - No such PB system classes to transform graphical objects. You would need some graphics library.

If you mean make large blob take up less memory, say from 200 kB to perhaps 20 kB then
YES - PowerBuilder can COMPRESS and decompress BLOBS - like zip and unzip.

See CompressorObject . Compress for details. PB even supports encrypting compressed data for extra protection.

HTH /Michael

Comment
Chris, I know, I expected CJ asked about image compression not blob compression. Luckily you could share image software experience.
  1. Michael Kramer
  2. Saturday, 22 February 2020 18:03 PM
Some image formats have built in compression, JPEG for example.
  1. Roland Smith
  2. Thursday, 5 March 2020 18:56 PM
True, also PNG, GIF, etc.

I remember back mid '80s running compressor (tree shaking) on compiled code to eliminate unused runtime overhead. Cut some (small) DOS apps in half. Different world back then; when 64 kB code segment was MASSIVE and Turbo Pascal 3/4 ruled the day! Turbo Pascal 5.5 added inheritance few years later, like 1988 or so.
  1. Michael Kramer
  2. Thursday, 5 March 2020 19:24 PM
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.