diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-26 00:25:34 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-26 19:05:34 +0200 |
commit | b2ad5380ad70de51075d67bbd9dd2145d1484b6a (patch) | |
tree | 0b42759eb9c297762d7f9987a3edfb31f502622e | |
parent | bcb57baaae2d7e6914ab4dd8eb5232aeacddbb72 (diff) |
Handle different basebmp scanline formats and flip vertically when needed
Change-Id: Ic0fd7d60ddc66bcd5577988b3a4e5b2185d3ec1f
-rw-r--r-- | ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm | 2 | ||||
-rw-r--r-- | vcl/coretext/salgdi.cxx | 34 |
2 files changed, 31 insertions, 5 deletions
diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm index 271342bd49d9..7e7216ff63b3 100644 --- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm +++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm @@ -26,7 +26,7 @@ static UIWindow *theWindow; (void) application; (void) launchOptions; - CGRect bounds = [[UIScreen mainScreen] applicationFrame]; + CGRect bounds = [[UIScreen mainScreen] bounds]; self.window = [[LOViewerWindow alloc] initWithFrame:bounds]; theWindow = self.window; diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx index c7db660ce834..7fdd97532176 100644 --- a/vcl/coretext/salgdi.cxx +++ b/vcl/coretext/salgdi.cxx @@ -30,6 +30,8 @@ #include <UIKit/UIKit.h> #include <postmac.h> +#include <basebmp/scanlineformats.hxx> + #include "saldatabasic.hxx" #include "headless/svpframe.hxx" #include "headless/svpgdi.hxx" @@ -284,17 +286,41 @@ bool SvpSalGraphics::CheckContext() basegfx::B2IVector size = m_aDevice->getSize(); basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer(); - mrContext = CGBitmapContextCreate(pixelBuffer.get(), size.getX(), size.getY(), 8, m_aDevice->getScanlineStride(), - CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast); + SAL_INFO( "vcl.ios", "CheckContext: device=" << m_aDevice.get() << " size=" << size.getX() << "x" << size.getY() << (m_aDevice->isTopDown() ? " top-down" : " bottom-up") << " stride=" << m_aDevice->getScanlineStride() ); + + switch( m_aDevice->getScanlineFormat() ) { + case basebmp::Format::EIGHT_BIT_PAL: + mrContext = CGBitmapContextCreate(pixelBuffer.get(), + size.getX(), size.getY(), + 8, m_aDevice->getScanlineStride(), + CGColorSpaceCreateDeviceGray(), + kCGImageAlphaNone); + break; + case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA: + mrContext = CGBitmapContextCreate(pixelBuffer.get(), + size.getX(), size.getY(), + 8, m_aDevice->getScanlineStride(), + CGColorSpaceCreateDeviceRGB(), + kCGImageAlphaNoneSkipLast); + break; + default: + SAL_INFO( "vcl.ios", "CheckContext: unsupported color format " << basebmp::Format::formatName( m_aDevice->getScanlineFormat() ) ); + } SAL_WARN_IF( mrContext == NULL, "vcl.ios", "CheckContext() failed" ); - return (mrContext != NULL); + if( mrContext != NULL && m_aDevice->isTopDown() ) + { + CGContextTranslateCTM( mrContext, 0, size.getY() ); + CGContextScaleCTM( mrContext, 1, -1 ); + } + + return ( mrContext != NULL ); } CGContextRef SvpSalGraphics::GetContext() { - if (!mrContext) + if ( !mrContext ) CheckContext(); return mrContext; |