Page 1 of 2

Photos

Posted: Thu Jun 15, 2023 12:22 pm
by serge_girard
Hi there,

Does somebody know how to put autograph (some text) on a JPG/BMP/PNG file. Preferably in batch, complete folder...

Thx/Serge

Re: Photos

Posted: Thu Jun 15, 2023 2:11 pm
by gfilatov
serge_girard wrote: Thu Jun 15, 2023 12:22 pm Hi there,

Does somebody know how to put autograph (some text) on a JPG/BMP/PNG file. Preferably in batch, complete folder...
Hi Serge,

I think it's possible with the great BosTaurus library.

Please take a look at the simple procedure below:

Code: Select all

/*
*/
DECLARE WINDOW _HMG_SPLASHWINDOW
/*
*/
Procedure textout()
LOCAL hDC, BTstruct
LOCAL hBitmap, hBitmap_aux
LOCAL nTypeText
LOCAL nAlingText
LOCAL nOrientation
LOCAL nW := BT_BitmapWidth(_HMG_SPLASHWINDOW.IMAGE.hBitmap)
LOCAL nH := BT_BitmapHeight(_HMG_SPLASHWINDOW.IMAGE.hBitmap)

   // Create bitmap in memory
   hBitmap := BT_BitmapCreateNew (nW, nH, WHITE)

   // Create hDC to a bitmap
   hDC := BT_CreateDC (hBitmap, BT_HDC_BITMAP, @BTstruct)     

     // Paste image
     hBitmap_aux := BT_BitmapLoadFile ("Splash")  // load from resource
        BT_DrawBitmapTransparent (hDC, 0, 0, nW, nH, BT_SCALE, hBitmap_aux, NIL)
     BT_BitmapRelease (hBitmap_aux)

     // Draw Text
     nTypeText    := BT_TEXT_TRANSPARENT + BT_TEXT_BOLD + BT_TEXT_ITALIC
     nAlingText   := BT_TEXT_LEFT + BT_TEXT_TOP
     nOrientation := BT_TEXT_NORMAL_ORIENTATION
     BT_DrawText (hDC, 450, 350, "EXTENDED", "Times New Roman", 18, BLACK, WHITE, nTypeText, nAlingText, nOrientation)

      BT_BitmapSaveFile( hBitmap, "test.png", BT_FILEFORMAT_PNG )
   // Release hDC bitmap
   BT_DeleteDC (BTstruct)

   _HMG_SPLASHWINDOW.IMAGE.hBitmap := hBitmap
   _HMG_SPLASHWINDOW.IMAGE.Refresh()

Return
The splash screen resource before conversion is shown below:
hmgsplash.png
hmgsplash.png (179.1 KiB) Viewed 3582 times
and the result image with added text is
test.png
test.png (187.76 KiB) Viewed 3582 times

Re: Photos

Posted: Thu Jun 15, 2023 3:01 pm
by serge_girard
Thanks Grigory, I will try !

Serge

Re: Photos

Posted: Thu Jun 15, 2023 4:01 pm
by Red2
Hello All,

I am very interested in this but could not run the code in "Official HMG".

The sample code eventually compiled when I changed "dot separated" syntax such as
_HMG_SPLASHWINDOW.IMAGE.hBitmap
into GetProperty(...) syntax.

However I cannot fix the following _HMG_SPLASHWINDOW error:
2023-06-15.png
2023-06-15.png (10.05 KiB) Viewed 3563 times
Any help on what I am missing would be greatly appreciated!
Thank you!

Re: Photos

Posted: Thu Jun 15, 2023 4:13 pm
by gfilatov
Hello Spencer,

Thanks for your interest.

You can find the source code for this example along with the executable in the attachment below.

But the above code is for use with MiniGUI Extended Edition. :o

Re: Photos

Posted: Thu Jun 15, 2023 4:36 pm
by Red2
Thank you very much Gregory!!!

Re: Photos

Posted: Thu Jun 15, 2023 4:50 pm
by serge_girard
Hi,

I'm adapting to my needs: row, col, text, color, font, size,.... will all be variable and to be edited on form.
Next step is to 'stamp' all (or some) photo with this text.

Serge

Re: Photos

Posted: Thu Jun 15, 2023 4:53 pm
by serge_girard
Grigory,

Any idea how to 'undo' or reset some mistaken text (when not yet save of course) ?

Serge

Re: Photos

Posted: Thu Jun 15, 2023 5:49 pm
by gfilatov
Serge,

Please take a look at the updated sample with Undo effect in the attachment.

Hope that give you some idea :idea:

Re: Photos

Posted: Thu Jun 15, 2023 9:50 pm
by AUGE_OHR
hi,

can not open ZIP Files as Windows Defender give a Error Message about "Trojan_WACATAC.B!ML"
Trojan_WACATAC.B!ML.jpg
Trojan_WACATAC.B!ML.jpg (15.56 KiB) Viewed 3502 times