UA is update too often



  • I have a User Area (UA) where I display thumbnails from image files.
    I scale the image files in DrawMsg().

    result, ismovie = self.bmp.InitWith(path)
    width, height = self.bmp.GetSize()
    self.DrawBitmap(self.bmp, x1, y1, 100, 100, 0, 0, width, height, c4d.BMP_NORMAL)
    

    This of course takes some time.

    I noticed that the UA (and thus the image files scaled) is often updated.
    For example, when I click in the UA or I move the slider of the UA.

    What can I do to make it more efficient?



  • Hello,

    as always, efficiency is the result of good software design. One way of speeding things up is to use caches.

    DrawMsg() is called by Cinema whenever Cinema things something might have changed. I don't think you can do anything about that.

    You have to make sure that within DrawMsg() you only draw and do nothing else. Why are you loading the bitmap in the context of DrawMsg()? Why are you scaling the images in the context of DrawMsg()? Why not earlier?

    I guess at some point, your program knowns what images to display. At that point you could load all these (scaled) images into a cache. Then in DrawMsg(), you can simply access the data in that cache.

    Compare e.g. BaseShader.InitRender() which is used to do all the heavy lifting, so that BaseShader.Sample() can be fast.

    Depending on the reason for the redraw, you could optimize further. E.g. you could use a GeClipMap to draw whatever you want into a BaseBitmap and simply draw that BaseBitmap in the context of DrawMsg().

    Speed is the result of software design. Caches can help, but of course they increase code complexity and memory footprint.

    Best wishes,
    Sebastian



  • Thanks for the answer.
    And yes, you are fully correct. Things should not be done in DrawMsg()


Log in to reply