Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The best way to save multiple images?
#1
If you have seen my site recently you know that I am working on my sprite editor, which can have up to 200 frames each. I need a good way to save them together. Each image can be a different size, and there is no way of knowing beforehand how many frames there will be (1 - 200). I have many thoughts.:

1) BSAVEing every single one into one sprite file.

2) BSAVEing each image into a bitmap and saving the path to the bitmap in the sprite file.

3) stacking multiple images into bitmaps, creating less of them with more images in each and saving the paths and positions into the sprite file.

4) stacking all images into one bitmap and saving just one path and positions and sized in the sprite file.

each has advantages and disadvantages. I need to have a nice balance of simplicity, speed, and memory usage. Which do you think is best? Is there another way?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
i save all pics from ll into seperate bmps, each bmp includes all frames for that one object, then i store a header with the data, saying the frame x/y size and the number of frames in the image. works fine.
Reply
#3
how bout collecting the frames of the animation into a single file ?

animation header
number of frames
pointer to frame headers ' . . . this is just a placeholder
version ' . . . for backward compatibility
frame header(0)
stuff
offset/pointer to frame(0) data
frame header(1)
. . .
frame header(number of frames)
frame(0).data
frame(1).data
etc . . .

This demonstrates loading an animation
saving left as excersize for the reader Big Grin
Code:
type image_header field=1
  format as ubyte               ' whatever the heck you want here
  w as uinteger
  h as uinteger
  union                               'important part
    data as ubyte ptr  
    offset  as integer
  end union
end type

type animation field=1
  num_frames   as uinteger
  frame  as image_header ptr
  version as integer
end type

function load_file(n$) as animation pointer
  dim a as zstring ptr
  dim anim as animation pointer
  dim p as ubyte ptr
  dim as integer I,offset

  a=allocate(LOF(1)+5)    :if a=0 then return 0:exit function
  open n$ for binary as 1 :if ERR=2 then return 0:exit function
  a=input$( LOF(1),1)       'copy entire file into ram
  anim=a
  p=a
  anim->frame = a + sizeof(animation)
  for I=0 to anim->num_frames
    offset=anim->frame[i].offset              
    anim->frame[i].data = @p[offset]
  next I
  
  return anim
end function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)