KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Image parsing

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Oct 02, 2006 7:15 pm    Post subject: Image parsing Reply with quote

Okay, due to Shawns newest release....

In one of my projects, I have a background image that is 1000 x 1000.

Well anytime something changes it takes a huge amount of time to redraw any one portion of the form, and I am fairly sure it is due to the background image.

Using Shawns new build, could I break that up into 100 x 100 chunks and make the redraw happen ever so much faster?

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Oct 02, 2006 7:23 pm    Post subject: Reply with quote

The best thing to do - in terms of performance - is to break that background image up into a small "tile" - a repeating pattern - and then let dotnet tile the image over the entire background - its a builtin feature.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Oct 02, 2006 7:29 pm    Post subject: Reply with quote

Unfortunatly I don't see how I could "tile" this image.
My other thought was to break it up into 100 100x100 squares, and then use 100 panels and set the background accordingly to each panel.

My assumption for that was that a panel will only redraw if there is a change to it.

Currently I have the 100 panels, but the main form holds the background for all of the panels(tranparent panels) and the whole background has to redraw each time I make a change in any one panel.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Oct 02, 2006 11:53 pm    Post subject: Reply with quote

I would say your assumption is correct - that breaking the image up into smaller chunks (panels) would improve performance. You looking for an example using the new DrawImage method ?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Oct 03, 2006 12:19 am    Post subject: Reply with quote

Here's a quick example:

Code:

Break On

$System = CreateObject("Kixforms.System")

$Form = $System.Form
$Form.ClientWidth = 300
$Form.ClientHeight = 300

;;
;; load the bitmap
;;

$OldBitmap = $System.Bitmap.FromBase64String(ImageString())

;;
;; create another bitmap same size as form
;;

$NewBitmap = $System.Bitmap.FromSize($System.Size(300,300))

;;
;; copy the bitmap to our new bigger bitmap
;;

$NewGraphics = $System.Graphics.FromImage($NewBitmap)
$NewGraphics.DrawImage($OldBitmap,0,0,$NewBitmap.Width, $NewBitmap.Height)

;;
;; break the image up into chunks (30x30) and load image into panels
;;

$Left = 0
$Top = 0
For $i = 1 To 10
 For $j = 1 To 10

  ;; create the panel

  $Panel = $Form.Controls.Add($System.Panel())
  $Panel.Width = 30
  $Panel.Height = 30
  $Panel.Left = $Left
  $Panel.Top = $Top
  $Left = $Panel.Right

  ;; create the bitmap

  $Bitmap = $System.Bitmap.FromSize($System.Size(30,30))
  $Graphics = $System.Graphics.FromImage($Bitmap)
  $Graphics.DrawImage($NewBitmap,0,0,30,30,$Panel.Left,$Panel.Top,$Panel.Width,$Panel.Height)
  $Panel.BackgroundImage = $Bitmap

  ;; set a random border to show effect

  $Panel.BorderStyle = iif(rnd(1),0,2)

 Next
 $Top = $Panel.Bottom
 $Left = 0
Next

;$Form.BackgroundImage = $NewBitmap

$Form.Center
$Form.Show
While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0


Function ImageString()
$ImageString = "
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL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7V2OtXc3lWzbubj7O8h9f3WcfTNFFZAdj4VGNKf8A
67N/IUUUVrD4UJbH/9k=
"
EndFunction
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Oct 03, 2006 12:41 am    Post subject: Reply with quote

I am not understanding why you do this part
Code:

;;
;; copy the bitmap to our new bigger bitmap
;;

$NewGraphics = $System.Graphics.FromImage($NewBitmap)
$NewGraphics.DrawImage($OldBitmap,0,0,$NewBitmap.Width, $NewBitmap.Height)


Otherwise yes that is exactly what I was thinking.

Do you believe this would increase performance based upon my earlier points (I.E. redraw a panel instead of a form)

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Oct 03, 2006 1:05 am    Post subject: Reply with quote

I did that just to increase the size of the original bitmap from 100x100 to 300x300 ... just made it bigger. you would have to try it to see if it helps any though - idk.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Oct 03, 2006 2:45 am    Post subject: Reply with quote

Thanks Shawn, I will play with this on Wednesday.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Tue Oct 03, 2006 9:13 am    Post subject: Reply with quote

Ummm Garg,

just for the records ... don't you have only 10 panels?

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Oct 03, 2006 12:18 pm    Post subject: Reply with quote

Nope, there are 100 "game" panels, and several others that are not affected by the background image.

Now if you want to talk about binary and only having 10 parents Smile

Code:

$t = 750
$l = 0
For $a=1 to 100 step 20
$t = $t -75
$l = 0
   For $forward = $a to $a+10 step 1    
      $nul = Execute("$Panel"+$forward+" = $System.Panel()")
      $nul = Execute("$Panel"+$forward+".BorderStyle = 1")
      $nul = Execute("$Panel"+$forward+".Left = "+$l)
      $nul = Execute("$Panel"+$forward+".Top = "+$t)
      $nul = Execute("$Panel"+$forward+".Width = 100")
      $nul = Execute("$Panel"+$forward+".Height = 75")
      $nul = Execute("$Panel"+$forward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$forward+")")
      $l = $l + 100
   Next
$t = $t -75
$l = 0
   For $backward = $a+19 to $a+10 step -1
      $nul = Execute("$Panel"+$backward+" = $System.Panel()")
      $nul = Execute("$Panel"+$backward+".BorderStyle = 1")
      $nul = Execute("$Panel"+$backward+".Left = "+$l)
      $nul = Execute("$Panel"+$backward+".Top = "+$t)
      $nul = Execute("$Panel"+$backward+".Width = 100")
      $nul = Execute("$Panel"+$backward+".Height = 75")
      $nul = Execute("$Panel"+$backward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$backward+")")
      $l = $l + 100
   Next
Next

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group