Page 1 of 1

movable text on an image?

Posted: Mon Feb 11, 2008 7:21 am
by DataMiner
Hi everybody!
For my father i created a simple image viewer, because my father hate to have 25 Buttons on a window. This was quiet simple to build. But now he ask me for drawing text on an image. Good, just use DrawText, i thought, but how can i get this text movable and editable after drawing??? And, with saving this modified image, keep it movable and editable???
I am grateful for each Note!

Posted: Tue Feb 12, 2008 9:33 am
by dige
I would do it like this:
Create a new image with same size, like the viewed image and
fill it with #white color.

Use the PB Commands to draw the Text inside the white image
and mix the two images together to a third image.

Posted: Tue Feb 12, 2008 5:07 pm
by Xombie
DataMiner,

Here's a super-basic ugly example for you.

Code: Select all

EnableExplicit
UsePNGImageDecoder()
LoadImage(0, "c:\temp\bliss.png")
CopyImage(0, 1)
If OpenWindow(0, 0, 0, ImageWidth(0) + 15, ImageHeight(0) + 15, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_TitleBar)
   ;
   If CreateGadgetList(WindowID(0))
      ImageGadget(0, 0, 0, ImageWidth(0), ImageHeight(0), ImageID(0), #PB_Image_Border)
   EndIf
   ;
EndIf
Define.l EventID
Repeat
   EventID = WaitWindowEvent()
   If EventID = #PB_Event_CloseWindow 
      Break
   ElseIf EventID = #WM_MOUSEMOVE
      FreeImage(0) : CopyImage(1, 0)
      StartDrawing(ImageOutput(0))
         DrawText(WindowMouseX(0), WindowMouseY(0), "Hello!")
      StopDrawing()
      SetGadgetState(0, ImageID(0))
   ElseIf EventID = #PB_Event_Gadget 
   EndIf
ForEver

Posted: Tue Feb 12, 2008 5:22 pm
by DataMiner
:D Thank you very much! Both of you!
I'll think about your hints ...