0

The following code stretches a bitmap, blends it with an existing background, maintains transparent area of primary graphic and then displays the blend within a window (imgScreen). This works fine when the level of stretch is not large or when it is actually shrinking the initial bitmap. However when stretching the graphic it is very slow.

I have limited experience with C++ and this kind of graphics so perhaps there is another more efficient way to do this. The primary bitmap to be sized is always square. Any ideas are much appreciated..!

I was going to try not displaying clipping area but from tests it seems the initial stretch is causing the slowdown... Also having trouble seeing how to calculate non clipped area... Drawing to controls seems a waste but seems only way to use built in functions like stretchdraw and the alpha draw option.

std::auto_ptr<Graphics::TBitmap> bmap(new Graphics::TBitmap);
std::auto_ptr<Graphics::TBitmap> bmap1(new Graphics::TBitmap);

int s = newsize;
TRect sR = Rect(X,Y,X+s,Y+s);
TRect tR = Rect(0,0,s,s); 
bmap->SetSize(s,s);
bmap->Canvas->StretchDraw(Rect(0, 0, s, s), Form1->Image4->Picture- 
>Bitmap); // scale
bmap1->SetSize(s,s);
bmap1->Canvas->CopyRect(tR, Form1->imgScreen->Canvas, sR);  //background
bmap1->Canvas->Draw(0,0,bmap.get()); // combine
Form1->imgTemp->Picture->Assign(bmap1.get());
Form1->imgScreen->Canvas->Draw(X,Y, Form1->imgTemp->Picture->Bitmap, 
alpha);

Displays correctly but as graphic gets larger draw rate slows down quickly...

Spektre
  • 49,595
  • 11
  • 110
  • 380
Jim
  • 45
  • 7
  • Mmm, this deals specifically with Embarcadero's C++, huh? Might be hard to find people who can work with this. – Bartek Banachewicz Jan 15 '19 at 11:41
  • @BartekBanachewicz some of us here are still active in BCB/BDS/etc.... builder (even professionally) related questions tend to get good answers quite fast in comparison to other tags I scan... This one was wrongly tagged that is why no answers where here... I only found this due to duplication with https://stackoverflow.com/q/54185017/2521214 – Spektre Jan 15 '19 at 11:54
  • You can write the magnification your self in the same way I did the Blending in your other question you just implement nearest neighbor (fastest) or bilinear filtering or higher order polynomial ... – Spektre Jan 16 '19 at 11:01
  • There is some confusion regarding these questions... Note the date... I resolved most of this stuff a while ago... The Scanline does solve the problem when implemented correctly but I really don't yet understand how to use it... The use of pointers and certain types, structs and so on are outside my experience... I have been doing C for about a year on and off... I also have limited time and when something looks like Chinese to me I tend to move on to something I know until I have a lot of time to play with. – Jim Jan 17 '19 at 04:07

0 Answers0