News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

[SOLVED] I can't get an image with GetImage

Started by cybermind, July 23, 2013, 01:50:54 PM

Previous topic - Next topic

cybermind

I am trying to grab a series of images for an animation. Image 800 is blank and 801 is not there at all (I can draw image 800 but nothing shows and trying to draw image 801 causes an error saying it doesn't exist). If I draw the original image 799 it shows allright.

PlayBASIC Code: [Select]
if last_anim_to_load_in_final_anims_list > 0
current_frame_to_load = 800
for anim = 1 to last_anim_to_load_in_final_anims_list
`load the bitmap itself from harddrive, 32x32 bitmaps
LoadImage final_file_list_for_map_anims$(anim),799
anim_frames = 8
grab_x = 0
x_size_of_each_frame = GetImageWidth(799) / 8
y_size_of_each_frame = GetImageHeight(799)
last_frame = current_frame_to_load+8
RenderToImage 799
for t = current_frame_to_load to last_frame
`copy source image to destination image
GetImage current_frame_to_load,grab_x,0,grab_x+x_size_of_each_frame,y_size_of_each_frame
grab_x = grab_x + x_size_of_each_frame
ScaleImage current_frame_to_load,4,4,0
next t
current_frame_to_load = t + 1
next anim
endif
RenderToScreen


kevin



This section looks wrong to me,


PlayBASIC Code: [Select]
      for t = current_frame_to_load to last_frame
`copy source image to destination image
GetImage current_frame_to_load,grab_x,0,grab_x+x_size_of_each_frame,y_size_of_each_frame
grab_x = grab_x + x_size_of_each_frame
ScaleImage current_frame_to_load,4,4,0
next t




   the Loop runs counts through values between (and inclusive of) current_frame_to_load to Last_Frame,  but inside the loop,  the code uses the current_frame_to_load variable for the image index, rather than the loop counter T

   eg.

PlayBASIC Code: [Select]
      for t = current_frame_to_load to last_frame
`copy source image to destination image
GetImage t,grab_x,0,grab_x+x_size_of_each_frame,y_size_of_each_frame
grab_x = grab_x + x_size_of_each_frame
ScaleImage t,4,4,0
next t





cybermind

Oh man, how could I miss that! Thank you so much! Great help!

I have been porting some code from DarkBASIC Professionel, but I have not done a great job I can see now :-D PlayBASIC seems real fine by the way :-)