I want to create a class that gets some position parameters, draws a dot on an image on this position and saves it in a new image file.
I want this to happen several time, but every time, the previous dots are also painted.
public: MainComponent(float A, float F); //constructor Image exporty; Graphics* exportyGraphic;
//Get Image from Binary Data exporty = ImageCache::getFromMemory(BinaryData::axis_jpeg, BinaryData::axis_jpegSize); //Create Graphic with the image exportyGraphic = new Graphics(exporty); //Draw dots in the positions (F, A) exportyGraphic->setColour(Colours::red); for (int count = 0; count < bands; count++) exportyGraphic->fillEllipse(F, A, 10, 10); //Get save Directory and file Name FileChooser* fc = new FileChooser("Select Directory to export the Results", File::getSpecialLocation(File::userHomeDirectory), ".png", true, false); fc->browseForFileToSave(true); File destination = fc->getResult(); //create file File exportFile = destination; exportFile.create(); //write On file FileOutputStream stream(exportFile); PNGImageFormat png; png.writeImageToStream(exporty, stream); //Deconstruct exportyGraphic->~Graphics(); exporty.~Image();
In the Main function of my application, i create two times this class with two different positions F,A :
myMainComponent = new MainComponent(125, 30); myMainComponent = NULL; myMainComponent = new MainComponent(125, 0);
This pops up the saveFile window two times as expected.
The first image file has dot on 125,30 but the second has two dots in both 125,30 and 125,0 as you can see in the images below
How can i erase any previous draws that have been made?
Why two different implementations of the same class have common things?