Hi,
I want to scale down my image by 50% of its original width. For example, if I have an image of resolution 1366x768 then the resultant image should be of 683x768 resolution. I am drawing the bitmap image in GeUserArea using DrawBitmap().
For scaling, I have used bitmap->ScaleIt() and bitmap->ScaleBicubic() functions but no luck. The ScaleIt() function scales the image but not the object in it. The object looks exactly as it was in original image but what I want is the image should look like squeezed i.e. scaled down by 50% in width. The ScaleBicubic() is now working at all. Although my destination image is of small size than of source image, it is still not working. Please help me with this. Below is the source code that I am using:
// create new bitmap
AutoAlloc<BaseBitmap> scaledBitmap;
if (scaledBitmap == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// get source bitmap dimensions
const Int32 originalWidth = bitmap->GetBw();
const Int32 originalHeight = bitmap->GetBh();
// initialize new bitmap with half width of the size
const Float scale = 0.5;
const Float scaledWidth = originalWidth * scale;
const Float scaledHeight = originalHeight;
const IMAGERESULT result = scaledBitmap->Init((Int32)scaledWidth, (Int32)scaledHeight);
if (result != IMAGERESULT::IMAGERESULT_OK)
{
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
}
// fill new bitmap with scaled content of the source bitmap
const Int32 defaultBrightness = 256;
//bitmap->ScaleIt(scaledBitmap, defaultBrightness, true, false);
bitmap->ScaleBicubic(scaledBitmap, 0, 0, originalWidth, originalHeight, 0, 0, scaledWidth, scaledHeight);
ShowBitmap(scaledBitmap);
DrawBitmap(scaledBitmap, x, y, scaledWidth, imageHeight, 0, 0, scaledWidth, scaledHeight, BMP_NORMALSCALED);
Thanks in advance!
Edit a_block: Added code tags.