Hey there. Im working on a game that has variable screen resolution options. Instead of making a copy of every picture (background) in all resolutions, i decided to just use the ResizeImage command. Now it works fine when i dont use it but it takes a realy long time to load when i use this command! is there a way to speed it up or another way to resize w/ out the wait? Thanks
ResizeImage
Blitz3D Forums/Blitz3D Programming/ResizeImage Any reason why you can't resize the image the first time the program is run, and anytime the user wishes to adjust resolution, then save the image to the harddrive with an appropriate name eg "myimage640x480.bmp" so that upon running the game in that resolution it can load the already resized image from a previous execution of the program.
Thats a good idea. ill try it when i get my settings program running. I have an external exe that runs instead if the main one doesnt see a settings.ini. Sortof a firstrun program. ill just add that in there when its done.
From the forums (sorry for no credit)
; ------------------------------------------------------------------------------------------------------------------------------------- ; This function scales an image an arbitrary amount on the X and Y axis, and returns a pointer to the new image. ; The original image is not modified. ; ; The scale can either be a relative width and height, ie, 0.5 of the width of the original image, or it can be an exact size in pixels. ; If an exact size is desired, set ExactSize to true. ; ; This function is 80x faster than the ScaleImage function that comes with Blitz! ; ------------------------------------------------------------------------------------------------------------------------------------- Function ScaleImageFast(SrcImage, ScaleX#, ScaleY#, ExactSize=False) Local SrcWidth, SrcHeight Local DestWidth, DestHeight Local ScratchImage, DestImage Local SrcBuffer, ScratchBuffer, DestBuffer Local X1, Y1, X2, Y2 ; Get the width and height of the source image. SrcWidth = ImageWidth(SrcImage) SrcHeight = ImageHeight(SrcImage) ; Calculate the width and height of the dest image, or the scale. If ExactSize = False DestWidth = Floor(SrcWidth * ScaleX#) DestHeight = Floor(SrcHeight * ScaleY#) Else DestWidth = ScaleX# DestHeight = ScaleY# ScaleX# = Float(DestWidth) / Float(SrcWidth) ScaleY# = Float(DestHeight) / Float(SrcHeight) EndIf ; If the image does not need to be scaled, just copy the image and exit the function. If (SrcWidth = DestWidth) And (SrcHeight = DestHeight) Then Return CopyImage(SrcImage) ; Create a scratch image that is as tall as the source image, and as wide as the destination image. ScratchImage = CreateImage(DestWidth, SrcHeight, 1, 1) ; Create the destination image. DestImage = CreateImage(DestWidth, DestHeight, 1, 1) ; Get pointers to the image buffers. SrcBuffer = ImageBuffer(SrcImage) ScratchBuffer = ImageBuffer(ScratchImage) DestBuffer = ImageBuffer(DestImage) ; Duplicate columns from source image to scratch image. For X2 = 0 To DestWidth-1 X1 = Floor(X2 / ScaleX#) CopyRect X1, 0, 1, SrcHeight, X2, 0, SrcBuffer, ScratchBuffer Next ; Duplicate rows from scratch image to destination image. For Y2 = 0 To DestHeight-1 Y1 = Floor(Y2 / ScaleY#) CopyRect 0, Y1, DestWidth, 1, 0, Y2, ScratchBuffer, DestBuffer Next ; Free the scratch image. FreeImage ScratchImage ; Return the new image. Return DestImage End Function