FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour generar bmp con texto
Posts: 0
Joined: unknown

generar bmp con texto

Posted: Fri Aug 27, 2021 10:18 PM

Hola gente, necesito leer una imagen bmp/jpg agregarle un texto y guardarla.

Saludos.
Jorge

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: generar bmp con texto

Posted: Sat Aug 28, 2021 01:35 AM
Code (fw): Select all Collapse
function TextOnImage()

   local hBmp
   local cSrcImage   := "c:\fwh\bitmaps\olga1.jpg"
   local cDstImage   := "olganame.jpg"
   local cText       := "Olga" + CRLF + "Kurylenko"
   local oFont, oLarg, oSmal

   DEFINE FONT oLarg NAME "VERDANA" SIZE 0,-50
   DEFINE FONT oFont NAME "TAHOMA"  SIZE 0,-30
   DEFINE FONT oSmal NAME "TAHOMA"  SIZE 0,-16

   hBmp  :=  FW_MakeYourBitmap( 352, 450, <|hDC, w, h |
               FW_DrawImage( hDC, cSrcImage, { 0, 0, h, w } )
               FW_SayText( hDC, cText, { 0, 0, h-30, w }, "B", { oLarg, oFont } )
               FW_SayText( hDC, "FWH Image Functions", { 30, 0, h, w }, "T", oSmal )
               return nil
               > )

   FW_SaveImage( hBmp, cDstImage, 100 )

   XImage( cDstImage )

   // cleanup
   DeleteObject( hBmp )
   RELEASE FONT oLarg,oFont, oSmal

return nil


Regards



G. N. Rao.

Hyderabad, India
Posts: 0
Joined: unknown

Re: generar bmp con texto

Posted: Sat Aug 28, 2021 10:12 AM

Hola, me da error al compilar, por lo que leí tengo una versión vieja, tengo 17.09.

Alguna otra forma, se podrá.

Saludos
Jorge.

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: generar bmp con texto

Posted: Sun Aug 29, 2021 09:13 AM
Mr. Rao,

I looked into the source of : * imgtxtio.prg where these functions are. (shadow, ...) maybe some more fancy stuff

What approch would you suggest for generating (in a loop) several new image combined with (second jpg or textual) for having this kind of result :

https://www.maveco-webshop.be/outlet/schoenen/

The discount text is a second image that is merged by the shop software, but it can be only 1 merged item.

With FW i could generate the image from source with all items on it and than upload. ( discount, OnStock, Sold Out, Promotion )
Marc Venken

Using: FWH 23.08 with Harbour

Continue the discussion