From 17b624959b5768017a52fdc723059307155e21a9 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Fri, 7 Apr 2006 18:35:04 +0000 Subject: [PATCH] bug 332713 support getting image pixel data back for an optimized image r=stuart --- gfx/src/thebes/nsThebesImage.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gfx/src/thebes/nsThebesImage.cpp b/gfx/src/thebes/nsThebesImage.cpp index 864f4f73b4af..290a8f0eb350 100644 --- a/gfx/src/thebes/nsThebesImage.cpp +++ b/gfx/src/thebes/nsThebesImage.cpp @@ -208,6 +208,21 @@ nsThebesImage::LockImagePixels(PRBool aMaskPixels) { if (aMaskPixels) return NS_ERROR_NOT_IMPLEMENTED; + if (mOptSurface && !mImageSurface) { + // Recover the pixels + mImageSurface = new gfxImageSurface(gfxImageSurface::ImageFormatARGB32, + mWidth, mHeight); + if (!mImageSurface) + return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr context = new gfxContext(mImageSurface); + if (!context) { + mImageSurface = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + context->SetOperator(gfxContext::OPERATOR_SOURCE); + context->SetSource(mOptSurface); + context->Paint(); + } return NS_OK; } @@ -216,6 +231,10 @@ nsThebesImage::UnlockImagePixels(PRBool aMaskPixels) { if (aMaskPixels) return NS_ERROR_NOT_IMPLEMENTED; + if (mImageSurface && mOptSurface) { + // Don't need the pixel data anymore + mImageSurface = nsnull; + } return NS_OK; }