Board index » cppbuilder » Bitmap->Canvas->Draw

Bitmap->Canvas->Draw

I am having a problem :)

I'm using NT

I am creating 2 offscreen TBitmaps
Transparent=true, monochrome=true, pallete = 0

Code flow:
On Click handler
First I create 1stBitmap
While loop (until end of data file)
create 2ndBitmap
I draw on the second one with the pixels property.
I use 1stBitmap->Canvas->Draw(x,y,2ndBitmap);
delete 2ndBitmap;
end while loop
TImage->Picture->Bitmap = 1stBitmap;
delete 1stBitmap;

This app runs perfectly except......
At random, some of the images(2ndBitmap) do not get copied to the main
bitmap(1stBitmap)
I have debugged by saving these images to file before calling the draw
method and they all turn out perfect in the file but still some do not copy.
It's never the same one every time.

Note: by switching the priority level in NT Task Manager to RealTime, I can
get this problem to go away.

Problem:  I cant ask an operator to switch the priority level in task
manager (anyone know how to do this from code?) and even if I could change
the priority, I don't want to.  This causes lag in the application and this
only bandaids the real problem.  (Anyone have an idea of what the real
problem is?)

Any help would be greatly appreciated.

Chris H.

 

Re:Bitmap->Canvas->Draw


Chris,
        You might be putting too much of a demand on your system with the
mutiple creation/deletion of the @nd bitmap and drawing on it using the
Pixels property as it is really slow.  Does the data file contain the
raw bits of your bitmap?  You might want to try partitioning your
tasks...

//from the size of your data file, determine the number of bitmaps
needed
//then create all of them at once

Graphics::TBitmap **MyBitmaps = new Graphics::TBitmap * [amount_needed];
for (int index = 0; index < amount_needed; index++)
{
        MyBitmaps[index] = new Graphics::TBitmap(this);
        MyBitmaps[index]->Parent = this;

Quote
}

//draw on each of the created bitmaps
//be sure to set the height and width of each bitmap

MyBitmaps[0]->Height = 250;
MyBitmaps[0]->Width = 200;

...

//draw each of the bitmaps directly onto the TImage

for (index = 0; index < amount_needed; index++)
Image1->Canvas->Draw(x, y, MyBitmaps[index]->Canvas);

//delete all your bitmaps

Alternatively, you can use a TImageList if all your smaller bitmaps are
of the same dimensions.  Good luck.

Damon Chandler
dm...@cornell.edu

Other Threads