Mitch, here the code that is causing the problem. I have cut a lot out but hopefully there is enough to show you. It probably wont run as it is.
Code: Select all
UseJPEGImageDecoder()
UseJPEGImageEncoder()
Enumeration
#Window_PI
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_0
EndEnumeration
Enumeration
#MPI2
#MPI3
#MPI6
#MPI4
#GPI1
#GPI2
EndEnumeration
Procedure BalloonTip(WindowID, Gadget, Text$ , Title$, Icon)
ToolTip=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID(WindowID),0,GetModuleHandle_(0),0)
SendMessage_(ToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
SendMessage_(ToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
SendMessage_(ToolTip,#TTM_SETMAXTIPWIDTH,0,180)
Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
Balloon\uFlags=#TTF_IDISHWND | #TTF_SUBCLASS
Balloon\hwnd=GadgetID(Gadget)
Balloon\uID=GadgetID(Gadget)
Balloon\lpszText=@Text$
SendMessage_(ToolTip, #TTM_ADDTOOL, 0, Balloon)
If Title$ > ""
SendMessage_(ToolTip, #TTM_SETTITLE, Icon, @Title$)
EndIf
EndProcedure
Procedure open_window_PI()
If OpenWindow(#Window_PI, 0, 0, 538, 342, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered , "Prepare image")
If CreateMenu(#MenuBar_0, WindowID())
MenuTitle("File")
MenuItem(#MPI2, "Load")
MenuItem(#MPI3, "Save")
MenuBar()
MenuItem(#MPI6, "Quit")
EndIf
If CreateGadgetList(WindowID())
ImageGadget(#GPI1, 10, 0, 250, 250, Image0, #PB_Image_Border)
TrackBarGadget(#GPI2, 10, 250, 250, 30, 0, 10, #PB_TrackBar_Ticks)
BalloonTip(WindowID(), #GPI2, "Move right for more compression", "Compression level", #TOOLTIP_INFO_ICON)
;TrackBarGadget(#GPI3, 260, -5, 30, 250, 0, 10, #PB_TrackBar_Ticks | #PB_TrackBar_Vertical)
;BalloonTip(WindowID(), #GPI3, "Move up for greater zoom", "Image zoom control", #TOOLTIP_NO_ICON)
StringGadget(#GPI4, 335, 0, 160, 20, "", #PB_String_ReadOnly)
StringGadget(#GPI5, 335, 20, 160, 20, "", #PB_String_ReadOnly)
StringGadget(#GPI6, 325, 50, 190, 100, "",#PB_String_MultiLine)
ButtonGadget(#GPI7, 330, 155, 80, 20, "Font")
ButtonGadget(#GPI8, 440, 155, 70, 20, "Colour")
ButtonGadget(#GPI10, 390, 270, 60, 20, "Clear Text")
ButtonGadget(#GPI11, 330, 270, 50, 20, "Prepare")
BalloonTip(WindowID(),#GPI11,"Prepares picture ready for transmission","", #TOOLTIP_NO_ICON)
ButtonGadget(#GPI12, 460, 270, 50, 20, "Exit")
StringGadget(#GPI14, 270, 255, 45, 20, "", #PB_String_ReadOnly)
TextGadget(#GPI15, 245, 280, 75, 15, "% Compression")
TextGadget(#GPI16, 290, 5, 40, 15, "Orig", #PB_Text_Right)
TextGadget(#GPI17, 295, 25, 35, 15, "New", #PB_Text_Right)
TextGadget(#GPI18, 500, 0, 30, 20, "bytes")
TextGadget(#GPI19, 500, 20, 30, 20, "bytes")
Frame3DGadget(#GPI13, 320, 40, 200, 216, "") : ; around posn buttons
TextGadget(#GPI121, 336,240,100,14,"Text positions")
LoadImage(81,"tl.bmp")
ButtonImageGadget(#tl, 340, 180, 20, 20, UseImage(81))
BalloonTip(WindowID(),#tl,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(82,"tm.bmp")
ButtonImageGadget(#tm, 360, 180, 20, 20, UseImage(82))
BalloonTip(WindowID(),#tm,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(83,"tr.bmp")
ButtonImageGadget(#tr, 380, 180, 20, 20, UseImage(83))
BalloonTip(WindowID(),#tr,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(84,"ml.bmp")
ButtonImageGadget(#ml, 340, 200, 20, 20, UseImage(84))
BalloonTip(WindowID(),#ml,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(85,"m.bmp")
ButtonImageGadget(#m, 360, 200, 20, 20, UseImage(85))
BalloonTip(WindowID(),#m,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(86,"mr.bmp")
ButtonImageGadget(#mr, 380, 200, 20, 20, UseImage(86))
BalloonTip(WindowID(),#mr,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(87,"bl.bmp")
ButtonImageGadget(#bl, 340, 220, 20, 20, UseImage(87))
BalloonTip(WindowID(),#bl,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(88,"bm.bmp")
ButtonImageGadget(#bm, 360, 220, 20, 20, UseImage(88))
BalloonTip(WindowID(),#bm,"Positions text","", #TOOLTIP_NO_ICON)
LoadImage(89,"br.bmp")
ButtonImageGadget(#br, 380, 220, 20, 20, UseImage(89))
BalloonTip(WindowID(),#br,"Positions text","", #TOOLTIP_NO_ICON)
Frame3DGadget(#frame6, 325, 255, 190, 45, "")
ButtonGadget(#styleN, 415, 180, 45, 20, "Normal")
BalloonTip(WindowID(),#styleN,"Normal text","", #TOOLTIP_NO_ICON)
ButtonGadget(#style1, 465, 180, 45, 20, "Style 1")
BalloonTip(WindowID(),#style1,"Style 1 text","", #TOOLTIP_NO_ICON)
ButtonGadget(#style2, 415, 200, 45, 20, "Style 2")
BalloonTip(WindowID(),#style2,"Style 2 text","", #TOOLTIP_NO_ICON)
ButtonGadget(#style3, 465, 200, 45, 20, "Style 3")
BalloonTip(WindowID(),#style3,"Style 3 text","", #TOOLTIP_NO_ICON)
ButtonGadget(#style4, 415, 220, 45, 20, "Style 4")
BalloonTip(WindowID(),#style4,"Style 4 text","", #TOOLTIP_NO_ICON)
ButtonGadget(#style5, 465, 220, 45, 20, "Style 5")
BalloonTip(WindowID(),#style5,"Style 5 text","", #TOOLTIP_NO_ICON)
TextGadget(#GPI20,20,300,200,20,"LOAD PICTURE FIRST !")
If LoadImage(200,"windigi.ico")
SendMessage_(WindowID(#Window_PI), #WM_SETICON, 0, UseImage(200))
EndIf
EndIf
EndIf
EndProcedure
open_window_PI()
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadgetID()
Case #GPI2
Gosub compression
;Case #GPI3
; Gosub zoom
Case #GPI7 ; font
Gosub TextFont
Case #GPI8 ; colour
Gosub TextColor
Case #GPI10 ; clear text
SetGadgetText(#GPI6,"")
result=LoadImage(2,filename$)
CopyImage(2,3)
ActivateGadget(#GPI6)
Case #GPI11 ; prepare
; copy picture to main screen
Case #tl
px=5
py=5
Gosub Position
Case #tm
px=80
py=5
Gosub Position
Case #tr
px=165
py=5
Gosub Position
Case #ml
px=5
py=125
Gosub Position
Case #m
px=80
py=125
Gosub Position
Case #mr
px=165
py=125
Gosub Position
Case #bl
px=5
py=220
Gosub Position
Case #bm
px=80
py=220
Gosub Position
Case #br
px=165
py=220
Gosub Position
Case #styleN : ; normal
style=0
Case #style1 : ; shadow
style=1
Case #style2
style=2
Case #style3
style=3
Case #style4
style=4
Case #style5
style=5
Case #GPI12 ; exit
quit=1
EndSelect
Case #PB_Event_Menu
Select EventMenuID()
Case #MPI2 ; load JPG file
Gosub loadpicture
Case #MPI3 ; save
Gosub savepicture
Case #MPI6 ; quit
quit=1
EndSelect
EndSelect
Until (quit=1) Or (EventID = #PB_Event_CloseWindow)
Gosub clearpics
End
Return
; ____________ GOSUBS _______________
loadpicture:
Pattern$ = "Images (*.jpg)|*.jpg;*.jpg|All files (*.*)|*.*"
Pattern=0
filename$=OpenFileRequester("Load picture","C:\WinDigi\",Pattern$,Pattern)
result=LoadImage(2,filename$)
CopyImage(2,3)
SetGadgetText(#GPI4,Str(ImageWidth())+"x"+Str(ImageHeight()))
ResizeImage(2,249,249)
ImageGadget(#GPI1,10,1,249,249,UseImage(2))
ActivateGadget(#GPI6)
Return
ResizeImage(2,249,249)
ImageGadget(#GPI1,10,1,249,249,UseImage(2))
ActivateGadget(#GPI6)
Return
Position:
; reload picture
;result=LoadImage(2,filename$)
UseImage(3)
; load default font
If fontid=0
fontid=LoadFont(1,"Arial",12)
EndIf
SetGadgetText(#GPI4,Str(ImageWidth())+"x"+Str(ImageHeight()))
ResizeImage(3,249,249)
ImageGadget(#GPI1,10,1,249,249,UseImage(3))
handle=StartDrawing(ImageOutput())
DrawingMode(1)
; display font styles
If style=0
FrontColor(Red(Color),Green(Color),Blue(Color))
DrawingFont(fontid)
UseFont(1)
Locate(px,py)
Text$=GetGadgetText(#GPI6)
DrawText(Text$)
EndIf
If style=1
EndIf
If style=2
EndIf
If style=3
EndIf
If style=4
EndIf
If style=5
EndIf
StopDrawing()
ActivateGadget(#GPI6)
Return
TextFont:
handle=StartDrawing(ImageOutput())
FontName$ = "Arial" ; set initial font
FontSize = 20 ; set initial size
result.l = FontRequester(FontName$, FontSize,#PB_FontRequester_Effects )
fname$=SelectedFontName()
size=SelectedFontSize()
style=SelectedFontStyle()
Color=SelectedFontColor()
fontid=LoadFont(1,fname$,size,style)
DrawingFont(fontid)
FrontColor(Red(Color),Green(Color),Blue(Color))
SetGadgetFont(#GPI6,fontid)
StopDrawing()
ActivateGadget(#GPI6)
Return
TextColor:
Color.l = ColorRequester()
ActivateGadget(#GPI6)
Return
clearpics:
For xpc=1 To 10
DeleteFile("c:\windigi\temp"+Str(xpc)+".jpg")
Next xpc
Return