Hello,
been a while since I visited bytes.com, but I have an issue with GDIplus...
I'm currently developing on/for a Windows Server 2003 system and I'm running a Benchmark to find the fastest and most performent way of resizing a jpg file from MegaPixel format to 640 * 480 size.
Gdiplus currently offers the fastest way for me with a result of 3ms / resize.
I am however recieving random Access Violations exceptions and the small tool sometimes uses up to 2GB of ram when running.
I've had serious issues getting Gdiplus to work to the point it is now, but I have no clue whats causing the problem. It usually happens on the SetInterpolatio n function of a Graphic.
Above code is the Benchmark2 function zhich resizes an image 1000 times to calculate the time.
I'm also developing with Borland in Rad Studio 2007
been a while since I visited bytes.com, but I have an issue with GDIplus...
I'm currently developing on/for a Windows Server 2003 system and I'm running a Benchmark to find the fastest and most performent way of resizing a jpg file from MegaPixel format to 640 * 480 size.
Gdiplus currently offers the fastest way for me with a result of 3ms / resize.
I am however recieving random Access Violations exceptions and the small tool sometimes uses up to 2GB of ram when running.
I've had serious issues getting Gdiplus to work to the point it is now, but I have no clue whats causing the problem. It usually happens on the SetInterpolatio n function of a Graphic.
Code:
// Prepare GDIplus
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, 0);
// Prepare the the variables that we are going to need:
time_t startpoint, endpoint, point;
Progress->Min = 0;
Progress->Max = 999;
Progress->Position = 0;
double counter = 0;
// Tell the user what this benchmark entails
ShowMessage("This benchmark will compress 1 image 1000 times and write it to disk 1000 times using GDI+.");
// load the image from the disk
Gdiplus::Bitmap* original;
::LPWSTR name = "C:/test.jpg";
original->FromFile(name);
// Start the loop and set our start time:
startpoint = clock();
for(int i = 0; i < 1000; ++i)
{
// Set our start point
point = clock();
// Create a new bitmap
Gdiplus::Bitmap *resized = new Gdiplus::Bitmap(640, 480);
// Create a new Graphics
Gdiplus::Graphics *g;
g->FromImage(resized);
// Set the Interpolationmode
g->SetInterpolationMode(Gdiplus::InterpolationModeNearestNeighbor);
// Redraw our image
g->DrawImage(original, 0, 0, 0, 0, original->GetWidth(), original->GetHeight(), Gdiplus::UnitPixel);
counter += difftime(clock(), point);
// Cleanup our mess
delete resized;
// Increment Progress bar and display cpu load
Progress->StepBy(1);
// process messages
Application->ProcessMessages();
}
// fetch our endtime
endpoint = clock();
// Display the result:
LOG->Items->Add("GDI+ took about " + FloatToStr(difftime(endpoint, startpoint) / 1000) + " seconds.");
LOG->Items->Add("GDI+ :: average copy time = " + FloatToStr(counter / 1000) + " ms.");
// delete pointer
delete original;
// Stop Gdiplus
Gdiplus::GdiplusShutdown(gdiplusToken);
I'm also developing with Borland in Rad Studio 2007
Comment