10 Replies Latest reply on Jan 12, 2010 3:13 PM by Agenore990

    Unload some image's part

    Agenore990

      I work with a big amount of data ( bitmap ): 800 bitmap 2500*2500, so I thought to inizializate only some of these. If I move my map, other bitmap will be loaded and if I load more then 10-15 bitmap flash player crashes. So I would unload some part of bitmap: initially they are empy,then I fill them with image using CopyPixel, I would come back  deleting only some part of bitmap , as when it was empy, to no overloads computer

       

      Exscuse me for my bad english... I hope you understand!

        • 1. Re: Unload some image's part
          Jason Szeto Level 3

          BitmapData.dispose will unload that data.However, it will destroy all of the data in your BitmapData. Can you break up your one large bitmap into multiple smaller ones?

          • 2. Re: Unload some image's part
            Agenore990 Level 1

            No, I can't use smaller images, I have to only some part of map, becouse it's made by rhombus images

            • 3. Re: Unload some image's part
              pauland Level 4

              Why can't you break up the images into smaller ones?

              • 4. Re: Unload some image's part
                Agenore990 Level 1

                No, because I'm afraid that they take up too much RAM. If I divide them into 4 parts, I should declare 4 Bitmap Canvas and 4 instead of 1 Canvas and 1 Bitmap.

                • 5. Re: Unload some image's part
                  pauland Level 4

                  Agenore990 wrote:

                   

                  No, because I'm afraid that they take up too much RAM. If I divide them into 4 parts, I should declare 4 Bitmap Canvas and 4 instead of 1 Canvas and 1 Bitmap.

                  No, the opposite is true. You make a component that holds (say 3x3 canvases - like the face of a rubic cube). As the user moves over the map you move the face of the rubic cube. When a canvas moves out of the visible area, it gets reloaded with another map segment and moved into place to extend the visible map in the direction in which the map is moving. You save memory and loading time because the bitmaps will be very small, will load quickly and won't give you a huge memory footprint.

                  • 6. Re: Unload some image's part
                    Agenore990 Level 1

                    So if I make 25 canvas and 25 bitmap instead one, I have better performance, it isn't? It seems very strange, but I'll tray!

                    • 7. Re: Unload some image's part
                      pauland Level 4

                      I don't think that you understand.

                       

                      First of all consider how big an area of  the map is visible. Since you haven't said how big that area is, lets say it's 250x250. Currently your bitmaps are 2500x2500 in size and you have 800 of these. These are quite large bitmaps. You never need to load all of the bitmaps.

                       

                      With a display size of 250x250, you can roam over your map by only ever having at most four bitmaps loaded at any one time.

                       

                      Place a bitmap centralised in the viewing area. If the user moves left over the map, as second bitmap is loaded and placed on the left and now two bitmaps are scrolled right. Eventually the  newly loaded image will come into view. If the user continues scrolling left, as the scroll approaches the left edge, the original bitmap can be unloaded and replaced by the image that need to appear on the right and that is positioned to the left and scrolled as before. It requires a bit more care at the corner joins where four images may be visible at any one time.

                       

                      It's possible to divide the 2500x200 images into smaller tiles, making loading faster. Doing this you may need more images to be loaded at any one time, but they will be smaller than the original images. The exact number of tiles required depends on the relationship between the size of the viewable area and the size of the bitmaps used.

                       

                      I'm not sure I have explained this very well. I'm not sure from your description if you are already attempting to do this, but it seems not because you shouldn't need to manipulate the bitmaps at all beside changing their position.

                       

                      Paul

                      • 8. Re: Unload some image's part
                        Agenore990 Level 1

                        I make a dynamic map: new parts are loaded when the user move his position. These images are loaded, built and distributed automacallly by my script. These images are made by rhombuses with copypixel and I would unload only some part of the bitmap that are too far from the displayed parts

                        • 9. Re: Unload some image's part
                          pauland Level 4

                          I have no idea why you would need to be copying pixels. Just use the tiling technique and move the image around and mask out the parts that don't need to be visible. I'm busy on some projects riht now or I'd make an example. The technique is often used for games.

                          • 10. Re: Unload some image's part
                            Agenore990 Level 1

                            I'll wait your exemple, becouse I can't understand