QImage::copy returns deep copy and has similar documentation so I assumed
that when docs say copy it means deep copy.
Let's consider common case:
1. QImage img created from raw data pointer got from e.g. driver.
2. img used in thread to perform some transforms
3. Save result as deep copy
Ensuring step 3 is most efficient and does not perform unnecessary copying
I need to write something like:
QTransform t;
if (m.type() == QTransform::TxNone)
return img.copy();
else
return img.transformed(m);
AFAIU img.transformed(m).copy() will copy twice when m.type() !=
QTransform::TxNone right?
Don't you think that is seems strange and is not documented enough?
2016-07-11 10:59 GMT+01:00 Simon Hausmann <[email protected]>:
> Hi,
>
>
> Could you elaborate on what you see as the discrepancy between docs and
> implementation? The docs don't say whether
>
> it's a shallow or a deep copy, so it looks to me that the implementation
> is within the bounds of the docs.
>
>
> Plus it seems sensible to return a shallow copy, doesn't it?
>
>
>
> Simon
> ------------------------------
> *From:* Development <development-bounces+simon.hausmann=
> [email protected]> on behalf of Tomasz Olszak <[email protected]>
> *Sent:* Monday, July 11, 2016 11:38:06 AM
> *To:* [email protected]
> *Subject:* [Development] QImage::transformed returns shallow copy for
> QTransform::TxNone matrix type.
>
> Hello,
>
> QImage:: transformed(const QTransform &matrix, Qt::TransformationMode mode
> = Qt::FastTransformation) docs:
>
> "Returns a copy of the image that is transformed using the given
> transformation matrix and transformation mode."
>
> But if matrix.type() == QTransform::TxNone then shallow instead of deep
> copy is returned.
>
> I'm happy to submit a fix but I don't know what is expected behaviour?
> Should implementation follow docs or docs or docs follow implementation
> here?
>
> T.
>
>
>
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development