02-18-2013 09:43 AM
Hi,
I want to crop the largest image in bb10.How can i achieve this? any help would be appreciated..
thanks,
02-20-2013 06:47 AM
In Image view there will be certain QML properties such as scaling method. Perhaps they will help
02-20-2013 06:56 AM
I need to crop the image and upload to server, when i send to server without crop the image it won't send as like original image, some data's are truncated or something happen unnecessarily. When i received it from server some pixels are not displaying..
02-20-2013 07:01 AM
Are you using QML?
02-20-2013 07:02 AM
yes, but send the image data to server using c++ code.
02-20-2013 07:19 AM
Ok, perhaps u can crop it using qml.. And then allow C code to take over
For cropping in qml u can do the following: put the image in Rectangle and set Rectangle’s clip property to true. you will have to properly position Image with x and y properties.
Found the solution online, but seems legit!
02-20-2013 07:55 AM
Hi,
QImage can be used for this:
QImage image("initial_image.jpg");
QImage copy;
copy = image.copy( 0, 0, 128, 128);
copy.save("cropped_image.jpg");
QImage's contents can also be saved to QByteArray for sending them over network.
QImage can be converted to ImageView for displaying.
03-13-2013 10:42 AM
Can anyone please post the code snippet for cropping the image in BB10?
Thanks in advance.
03-14-2013 04:43 AM
Here is how I crop a cover image into a thumbnail:
QString tempPath = getAbsoluteTemporaryFolderPath() + filename;
QString thumbnailPath = comic->getThumnailPath();
QImageReader coverImageReader(tempPath);
QImage coverImage = coverImageReader.read();
qDebug() << "DataManager:: cover image width is " << coverImage.width();
if(coverImage.width() > 0)
{
qDebug() << "DataManager:: size of cover is " << coverImage.numBytes() << " bytes";
QImage result = coverImage.scaled(COVERWIDTH, COVERHEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation);
result.save(thumbnailPath, "PNG", 50);
qDebug() << "DataManager:: saved thumbnail to " << thumbnailPath;
}
else
{
qDebug() << "DataManager:: could not load temporary fullsize image";
}
03-15-2013 03:46 AM
Hi Zezke,
Thanks for the code. Actually my requirement is something different. I have a large image of size suppose 1600x1200. I have to place it inside a container of size 200 x 300 . So i want to crop the image from (0,0) position till (200, 300).
All the APIs provided in Qt/ QML scaling method are not supporting to do this. How to achieve this?
Thanks,
Uttam