Linie zeichnen
Verfasst: 30.06.2011 13:30
Hallo, habe folgendes Problem, will ein Image aufnehmen und mit Rotstift korrigieren. Möchte einfach eine Linie von A nach B ziehen und auf das Image zeichen. Komme nicht recht weiter, kann jemand helfen?
Nun das Beispiel geht wie folgt: linke Maustaste "START" und rechte Maustaste "ENDE" und die Linie zeichnen!
Gruss ... Velindos
Nun das Beispiel geht wie folgt: linke Maustaste "START" und rechte Maustaste "ENDE" und die Linie zeichnen!
Code: Alles auswählen
Enumeration
#Window_main
EndEnumeration
;
Enumeration
#Image_gadget
#Button_Neu
#Button_Speichern
#RotstifImage
EndEnumeration
Structure Punkt
x.l
y.l
EndStructure
MausPos.Punkt
CreateImage(#RotstifImage, 650, 650)
StartDrawing(ImageOutput(#RotstifImage))
Box(0, 0 , 650, 650, RGB(255,255,0))
StopDrawing()
Procedure Open_Window_main()
If OpenWindow(#Window_main, 0, 0, 667, 706, "Image Rotstift", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_main))
;ImageGadget(#Image_gadget, 40, 40, 520, 580, )
ImageGadget(#Image_gadget, 9, 53, 650, 650, ImageID(#RotstifImage))
EndIf
EndIf
EndProcedure
Open_window_main()
Repeat
event= WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case #image_gadget
Select EventType()
Case #PB_EventType_LeftClick
MausPos\x = WindowMouseX(#window_main)
MausPos\y = WindowMouseY(#window_main)
Debug Str(MausPos\x)+" ss " + Str(MausPos\y)
StartDrawing(ImageOutput(#RotstifImage))
;Box(MausPos\x -20, MausPos\y -20, 10, 10, RGB(0,0,255))
;Box(WindowMouseX(#window_main)-9, WindowMouseY(#window_main)-53, 1, 1, RGB(0,0,255))
;LineXY(WindowMouseX(#window_main)-9, WindowMouseY(#window_main)-53, 1, 1, RGB(0,0,255))
StartLinie_X=(WindowMouseX(#window_main)-9)
StartLinie_Y=(WindowMouseY(#window_main)-53)
StopDrawing()
Case #PB_EventType_RightClick
MausPos\x = WindowMouseX(#window_main)
MausPos\y = WindowMouseY(#window_main)
Debug Str(MausPos\x)+" ss " + Str(MausPos\y)
StartDrawing(ImageOutput(#RotstifImage))
;Box(MausPos\x -20, MausPos\y -20, 10, 10, RGB(0,0,255))
;Box(WindowMouseX(#window_main)-9, WindowMouseY(#window_main)-53, 1, 1, RGB(0,0,255))
LineXY(WindowMouseX(#window_main)-9, WindowMouseY(#window_main)-53, StartLinie_X, StartLinie_Y, RGB(248, 13, 7))
StopDrawing()
SetGadgetState(#image_gadget, ImageID(#RotstifImage))
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow