#169096 - 2006-10-09 08:17 PM
Re: Need HELP!
|
pvds
Hey THIS is FUN
   
Registered: 2001-04-14
Posts: 201
|
APRONK,
Sorry I now I did wrong but I realy need this to be solved here is the origanal post.
Can someone help me to solve this! After saving a jpg file I want to delete the original I use Dispose but somehow I am not lucky.
problem is in the SaveImage function
Please Help!
Code:
Break On
$Rect_Width = 100 $Rect_Height = 100 $Photo = @SCRIPTDIR + "\Foto\lara.jpg" $New_PhotoPath = @SCRIPTDIR + "\Foto\" $Empty_Photo = @SCRIPTDIR + "\Foto\Leeg2.jpg"
$System = CreateObject("Kixforms.System")
;$Bitmap = $System.Bitmap($Photo)
$Form = $System.Form $Form.ClientWidth = 400 $Form.ClientHeight = 600 $Timer1 = $System.timer() ; Create a timer $Timer1.Interval = 150 $Timer1.Tick = "Check_Photo()" $Panel1 = $Form.Controls.Add($System.Panel()) $Panel1.Top = 0 $Panel1.Left = 0 $Panel1.Width = 400 $Panel1.Height = 400 $Panel1.BackColor = $System.Color.red $Panel1.MouseMove = "PanelMouseMove($$System.Sender,$$System.EventArgs)" $Button1 = $Form.Controls.Add($System.Button()) $Button1.Top = 410 $Button1.Left = 10 $Button1.Text = "Opslaan" $Button1.Click = "SaveImage($MouseX, $MouseY)" $Button1.Width = 150 $TextBox1 = $Form.Controls.Add($System.TextBox()) $TextBox1.Top = $Button1.Top + 30 $TextBox1.Left = $Button1.Left $TextBox1.Text = Nummer $Label1 = $Form.Controls.Add($System.Label()) $Label1.Top = $Button1.Top + 60 $Label1.Left = $Button1.Left $Label1.Text = "" $Label1.Width = 150 $Timer1.Start ;Draw_Rect(0 - $Rect_Width - 10,0)
$Form.Center $Form.Show While $Form.Visible $= Execute($Form.DoEvents) Loop Exit 0
Function Draw_Rect($MouseX, $MouseY) $Bitmap = $System.Bitmap($Photo); $Plaatje = $System.Graphics.FromImage($Bitmap) If ($Bitmap <> "") $Plaatje.DrawRectangle($System.Pen($System.Color.DarkSlateBlue,3),$MouseX,$MouseY,$Rect_Width,$Rect_Height); $Panel1.BackgroundImage = $Bitmap $Bitmap = $System.Bitmap($Photo) $Panel1.Refresh() EndIf EndFunction
Function PanelMouseMove($Sender,$EventArgs) If ($Panel1.MouseButtons & $System.MouseButtons_Left) $MouseY = $Panel1.MousePosition.y - $form.top - 20 $MouseX = $Panel1.MousePosition.x - $form.Left - $panel1.Left Draw_Rect($MouseX, $MouseY) EndIf EndFunction
Function SaveImage($MouseX, $MouseY) $check = Val($Textbox1.Text)
If $check = 0 Or Len($check) <> 6 $Label1.Text = "Invul Fout" Else If Exist($New_PhotoPath + $Textbox1.Text + ".jpg") $Label1.Text = "Foto al aanwezig!" Else $Timer1.stop $NewImage = $Bitmap.Clone($MouseX,$MouseY,$Rect_Width,$Rect_Height) $NewImage.Save($New_PhotoPath + $TextBox1.Text + ".jpg") $Label1.Text = "Opgeslagen: " + $TextBox1.Text $TextBox1.Text = "Nummer" ;$System.Pen.Dispose ;? @ERROR $Bitmap.Dispose ? @ERROR
$NewImage.Dispose ? @ERROR Del $Photo ? @ERROR $Panel1.Refresh() $Timer1.start EndIf EndIf EndFunction
Function Check_Photo() If Dir($Photo) <> "" $Timer1.Stop Draw_Rect($MouseX, $MouseY) Else $Label1.Text = "Wacht" EndIf EndFunction
Edited by pvds (2006-10-09 10:39 PM)
|
|
Top
|
|
|
|
#169112 - 2006-10-13 05:13 AM
Re: Need HELP!
|
pvds
Hey THIS is FUN
   
Registered: 2001-04-14
Posts: 201
|
Quote:
Apparantly this isn't a KixForms problem but a .Net problem I have a similar problem using VB.Net. Haven't figured it out yet either :/
This ugly solution did the trick
Code:
Do $Bitmap.dispose $Panel1.BackgroundImage = $Orginal ; This is other bitmap Del $photo Until @ERROR = 0
Edited by pvds (2006-10-13 05:14 AM)
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1636 anonymous users online.
|
|
|