UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: cybermind on July 23, 2013, 01:50:54 PM

Title: [SOLVED] I can't get an image with GetImage
Post by: cybermind on July 23, 2013, 01:50:54 PM
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.

[pbcode]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
[/pbcode]
Title: Re: I can't get an image with GetImage
Post by: kevin on July 24, 2013, 02:10:00 AM


This section looks wrong to me,


[pbcode]

      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

[/pbcode]

   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.

[pbcode]

      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

[/pbcode]

Title: Re: I can't get an image with GetImage
Post by: cybermind on July 24, 2013, 03:54:53 AM
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 :-)