Good Evening!!
I've a couple of questions about the Bitmap class
and the various command that this class use i'm trying to calculate the time of execution of the Bitmap's methods
the ammount of RAM and CPU that the Methods use for example... is there an easy way to do it? like a table where all of this is contained
for example... what's the difference between these two Line of code in RAM and CPU:
@image = Sprite.new
@image.bitmap = RPG::Cache.picture("image.png") #for an image big n*32 width and m*32 height pxl
#---------------------------------------------------------------------------
@image = Sprite.new
@image.bitmap = Bitmap.new(n*32,m*32)
for i in 0..n-1
for j in 0..m-1
img = get_img(i,j)
@image.bitmap.blt(i*32,j*32,img,Rect.new(0,0,@image.width,@image.height))
end
end
I'm sure that the second way to do it have a bigger impact on the CPU usage...
but... if i try to do other action on this Sprites...
@image.x = @new_x
@image.y = @new_y
@image.zoom_x = @new_zx
@image.zoom_y = @new_zy
@image.mirror = @boolean_mir
assuming the case where the Sprite called @image is taken from a single PNG file
then the case where the Sprite is created with a merge of more pictures.PNG...
There is here a case where there is a lighter use of the CPU and of the RAM?
or it's the same thing?
there may be the case where n and m (width/32 and height/32 of the @image) are >= 100 for example.
I'll explain what i'm doing (so that you may have a better view of the problem)
I'm rewriting the Tilemap Class ('cause all the version i've seen have a lot of lag or glitch)
I've write a script that create a file .PNG (that will be saved in a directory "Temp") of the first layer of the map, then, when you load that particular map, put the .PNG at the same spot of the not-animated tiles of the first layer (the animated one will be print under the .PNG) the problem of this script is that it takes several seconds to create and save the .PNG (for a map 50x50 it takes 6 seconds) storing the previous Temporary maps, so you don't have to create it everytime, just the first time, and eventually again if you delete the file into the "Temp" directory.
So, does the composed Sprite (with the .bitmap.blt() method) takes the same time to be modified that takes the Sprite created with a single image (also if we're talking about a big image, with a lot of tiles merged together) or not?
==================================================================================
I've another question, always regarding the Bitmaps...
talking about the Animated-Autotiles...
is it easyer for the computer to update the animated graphic of a single tile in a bigger Sprite
or to manage several sprites that will be resetted with the new frame?
@image = Sprite.new
@image = Bitmap.new(n*32,m*32)
#previous code where i create the bitmap... etc...etc...
def update
n = @image.width/32
m = @image.height/32
for i in 0..n-1
for j in 0..m-1
for z in 0..2
if animated #if an animated autotile is detected in i,j,z coords
new_anim = get_autotile(i,j,z)
@image.bitmap.blt(i*32,j*32,new_anim,Rect.new(0,0,@image.width,@image.height)
end
end
end
end
#-------------------------------------------------------------------------------------------------------
@tiles = {}
n = @map_data.xsize
m = @map_data.ysize
for i in 0..n-1
for j in 0..m-1
for z in 0..2
coords = [i,j,z]
@tiles[coords] = Sprite.new
@tiles[coords].bitmap = get_autotile(i,j,z) #or the relative Tile, i can't go into the specifics here XD
@tiles[coords].x = i*32
@tiles[coords].y = j*32
end
end
end
#then, for the method update
def update
n = @map_data.xsize
m = @map_data.ysize
for i in 0..n-1
for j in 0..m-1
for z in 0..2
coords = [i,j,z]
if animated(coords)
new_autotile = get_autotile(i,j,z)
@tiles[coords].bitmap = new_autotile
end
end
end
end
end
I know for sure that to handle several Sprites is a bigger issue for the program... but i don't know if to edit a sector of a Bitmap (with .bitmap.blt()) is easy like setup a new image for the Bitmap (with .bitmap = var) do someone know the answer?
So... resuming all of this:
a single big bitmap (created with a picture, a file taken from a directory) called
single_bitmap
a big bitmap (created merging several images, with the .bitmap.blt() method) called
composed_bitmap
When the 2 images has been created... to edit single_bitmap is like edit the composed_bitmap? the RGSS think at the two of them like 2 simple images? the composed_bitmap is processed as a single image or as a composition of several images (also after the creation)?
and... the
.bitmap.blt() method has the same CPU and RAM usage of the command
.bitmap = var... or the second one is lighter? (delay of bitmap.blt() >> delay of bitmap = var)
is preferred to handle several Sprites, so that you can modify them one by one... or to handle a single composed Sprite that you have to edit?
Obviously if a composed_bitmap for the RGSS is still a group of several bitmap (and not a single image)... then the answer to the second question is immidiate ^_^
Thanks!! I really hope for an answer!!