Hi Klaus
I'm basically trying to assign a bitmap from (a) memory if previously loaded or (b) re-load if not found in memory. My thinking is that it be quicker to draw the tile from memory rather than reloading everytime from file. Below is the code i'm trying to use it in. It suitabily comment to see whats happening:
'1a Get handle "bmpTile" To tile file by (a) copying from ImageListArr If already loaded OR (b) re-laoding from jpg tile file:
For i=0 To ArrayLen(tilesCurrentlyInImageListArr())-1 'Note 'i' corresponds to tile posn on canvas as it cycles through, not mosaic, 1st posn (i.e. top left corner) is zero
If tilesCurrentlyInImageListArr(i).tileIndexOnMosaic = tileIndexOnMosaic1 Then
'Tile already loaded in ImageListArr
''#bmpTile.Create3(tilesImageListArrC.Item(i)) 'Assign tile as bmp from ImageListArray
bmpTile.New3(tilesImageListArrC.Item(i))
tilesImageListArrC.Item(tilePosnOnCanvas) = tilesImageListArrC.Item(i) 'Copy tile to correct posn in imageListArr for future use
tilesCurrentlyInImageListArr(i).tileIndexOnMosaic = tileIndexOnMosaic1 'Update array to keep track of what has been moved/copied
tileFoundinImageListArr = True
Msgbox ("Found in ImageListArr: " &CRLF& "tileIndexOnMosaic1=" & tileIndexOnMosaic1 & "; "& tileRowPosninMosaic&"-"&tileColPosninMosaic)
Exit 'tile loaded, so exit ForLoop
End If
Next
If tileFoundinImageListArr=False Then
'tile not found in ImageListArr (i.e. not already loaded), therefore load from file
tilefile = AppPath & "\tiles\" & tileFileNamePrefix & "-" & tileRowPosninMosaic & "-" & tileColPosninMosaic & ".jpg"
bmpTile.Create1(tilefile) 'Assign tile as bmp
tilesImageListArrC.Item(tilePosnOnCanvas) = bmpTile.Value 'Copy tile to imageListArr for future use
tilesCurrentlyInImageListArr(tilePosnOnCanvas).tileIndexOnMosaic = tileIndexOnMosaic1 'Update array to keep track of what has been copied
End If
'1b. Define source image area (i.e. WHOLE tile):
rectTile.X = 0 'Q: move to LoadMap as it it constant?
rectTile.Y = 0 'Q: move to LoadMap as it it constant?
rectTile.Width = TileWidth
rectTile.Height = TileHeight
'1c. Define destination image area (on canvas):
rectTileDestOnCanvas.X = x_pix_onCanvas
rectTileDestOnCanvas.Y = y_pix_onCanvas
rectTileDestOnCanvas.Width = tileWidth*zoom
rectTileDestOnCanvas.Height = tileHeight*zoom
'1d. Draw tile onto right position on canvas:
canvasDrawer.DrawImage(bmpTile.Value,rectTile.Value,rectTileDestOnCanvas.Value,False) 'copy tile onto canvas, zoomed as req'd