how to speed up LoadBrush(id, $file, {x, y, width, height})?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

how to speed up LoadBrush(id, $file, {x, y, width, height})?

Post by Bugala »

I noticed there is possiblity to load only part of picture using LoadBrush with idea that if you have several squares to grab from same picture, you could take them piece by piece.

So I did, but it appears to be very slow.

I have roughly 2500 x 2500 pixel picture where I am taking 128x 128 pieces out of it. That makes around 200 tilepieces.

However, It happens very, very slow. I think it takes maybe 3 minutes or something like that to complete the whole process of:

Code: Select all

n_brush=1

x=0
y=0

Repeat
   Repeat
      LoadBrush(n_brush, tiles.image, {x=x, y=y, width=tiles.tilewidth, height=tiles.tileheight})
      n_brush = n_brush + 1
      x = x + tiles.tilewidth 
      DebugPrint(x.." / "..y.."  n: "..n_brush)
   Until x > tiles.imagewidth-tiles.tilewidth
   x = 0
   y = y + tiles.tileheight
Until y > tiles.imageheight-tiles.tileheight 

Is there any way to speed thsi up, or do i have to perhaps load that picture as a brush and then keep making smaller brushes from that one big brush?

For my guess is that the slow down is that instead of loading just that small part of that picture, it probably loads that whole picture before taking that small piece making reloading of such a big picture very slow.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: how to speed up LoadBrush(id, $file, {x, y, width, height})?

Post by airsoftsoftwair »

LoadBrush() will always load the whole shebang and then crop it. So you cannot save loading time by specifying only a partial image area. That is because datatypes do not support partial image loading.
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

Re: how to speed up LoadBrush(id, $file, {x, y, width, height})?

Post by Bugala »

I just noticed copybrush didnt work the way i thought, that you cant copy only small piece of a brush.

Hence comes the question of, is there any way to do this same thing that I am trying to do?


Its not hard to save each brush individually and load next times, but at this point when I am testing only, I would rather use some simpler solution, but one that wouldnt take ages to execute.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: how to speed up LoadBrush(id, $file, {x, y, width, height})?

Post by airsoftsoftwair »

Create a new brush of the desired size, then use SelectBrush() and DisplayBrushPart() to copy a part from an existing brush to the new brush. This should be sufficiently fast.
Bugala
Posts: 1400
Joined: Sun Feb 14, 2010 7:11 pm

Re: how to speed up LoadBrush(id, $file, {x, y, width, height})?

Post by Bugala »

Thanks from that. Now it worked very fast again. I click on run and it starts with no need to wait.
Post Reply