ScaleIt in DrawMsg

On 30/11/2016 at 10:39, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   14 
Platform:   Windows  ;   
Language(s) :     C++  ;


I have a plugin where I'm trying to mimic the functionality of the Content Browser in Cinema. I have it displaying a large number of GeUserAreas which a user can change the scale of by using a slider. My code works and correctly changes the size of the different GeUserAreas but takes much longer to display than the Content Browser.

To try and speed it up I used GeGetMilliSeconds() to determine which parts of my code were taking the most time. The DrawMsg function for the GeUserAreas took up a large amount of the total time. Within DrawMsg it was the use of the ScaleIt function that used most of the time.

void ImageArea::DrawMsg(LONG x1, LONG y1, LONG x2, LONG y2, const BaseContainer& msg)  
//Used so saveImage isn't initialized every time DrawMsg is run  
  if(imageFound == FALSE)  
      if(saveImage->Init(picturePath) == IMAGERESULT_OK)  
      imageFound = TRUE;  
 saveImage->ScaleIt(tempImage, 256, TRUE, TRUE);//Takes up most of the time used by the function  
 DrawBitmap(tempImage, 0, 0, tempImage->GetBw(), tempImage->GetBh(), 0, 0, tempImage->GetBw(), tempImage->GetBh(), BMP_NORMALSCALED | BMP_ALLOWALPHA);  

Does anyone know of a way to optimize the DrawMsg function because it might be executing a hundred plus times on a single layout change so any inefficiency becomes a large problem. I've tried setting the Bool sample variable for ScaleIt to False and any effect that it had was negligible.

Any help would be greatly appreciated.

Johan H.

On 30/11/2016 at 10:43, xxxxxxxx wrote:

Just don't scale it and use the destination coordinate parameters to define the target image size. The
DrawBitmap() will scale the source into the destination region.

If you're still experiencing performance issues, I suggest removing the BMP_NORMALSCALED flag as it
makes the drawing extremely less performant.


On 30/11/2016 at 12:18, xxxxxxxx wrote:

Thanks for the quick reply Niklas, that solved the problem.

Johan H.