Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
702404fe
Commit
702404fe
authored
Mar 21, 2019
by
Laszlo Agocs
Browse files
Improve the readback docs
parent
580408d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/rhi/qrhi.cpp
View file @
702404fe
...
@@ -3637,8 +3637,7 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
...
@@ -3637,8 +3637,7 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
rbResult->completed = [rbResult] {
rbResult->completed = [rbResult] {
{
{
QImage::Format fmt = rbResult->format == QRhiTexture::BGRA8 ? QImage::Format_ARGB32_Premultiplied
const QImage::Format fmt = QImage::Format_RGBA8888_Premultiplied; // fits QRhiTexture::RGBA8
: QImage::Format_RGBA8888_Premultiplied;
const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
QImage image(p, rbResult->pixelSize.width(), rbResult->pixelSize.height(), fmt);
QImage image(p, rbResult->pixelSize.width(), rbResult->pixelSize.height(), fmt);
image.save("result.png");
image.save("result.png");
...
@@ -3655,6 +3654,16 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
...
@@ -3655,6 +3654,16 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
\note The texture must be created with QRhiTexture::UsedAsTransferSource.
\note The texture must be created with QRhiTexture::UsedAsTransferSource.
\note Multisample textures cannot be read back.
\note Multisample textures cannot be read back.
\note The readback returns raw byte data, in order to allow the applications
to interpret it in any way they see fit. Be aware of the blending settings
of rendering code: if the blending is set up to rely on premultiplied alpha,
the results of the readback must also be interpreted as Premultiplied.
\note When interpreting the resulting raw data, be aware that the readback
happens with a byte ordered format. A \l{QRhiTexture::RGBA8}{RGBA8} texture
maps therefore to byte ordered QImage formats, such as,
QImage::Format_RGBA8888.
*/
*/
void
QRhiResourceUpdateBatch
::
readBackTexture
(
const
QRhiReadbackDescription
&
rb
,
QRhiReadbackResult
*
result
)
void
QRhiResourceUpdateBatch
::
readBackTexture
(
const
QRhiReadbackDescription
&
rb
,
QRhiReadbackResult
*
result
)
{
{
...
...
src/rhi/qrhigles2.cpp
View file @
702404fe
...
@@ -1579,6 +1579,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
...
@@ -1579,6 +1579,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
// readPixels handles multisample resolving implicitly
// readPixels handles multisample resolving implicitly
}
}
result
->
data
.
resize
(
result
->
pixelSize
.
width
()
*
result
->
pixelSize
.
height
()
*
4
);
result
->
data
.
resize
(
result
->
pixelSize
.
width
()
*
result
->
pixelSize
.
height
()
*
4
);
// With GLES (2.0?) GL_RGBA is the only mandated readback format, so stick with it.
f
->
glReadPixels
(
0
,
0
,
result
->
pixelSize
.
width
(),
result
->
pixelSize
.
height
(),
f
->
glReadPixels
(
0
,
0
,
result
->
pixelSize
.
width
(),
result
->
pixelSize
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
result
->
data
.
data
());
result
->
data
.
data
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment