Kaydet (Commit) b2ad5380 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Handle different basebmp scanline formats and flip vertically when needed

Change-Id: Ic0fd7d60ddc66bcd5577988b3a4e5b2185d3ec1f
üst bcb57baa
...@@ -26,7 +26,7 @@ static UIWindow *theWindow; ...@@ -26,7 +26,7 @@ static UIWindow *theWindow;
(void) application; (void) application;
(void) launchOptions; (void) launchOptions;
CGRect bounds = [[UIScreen mainScreen] applicationFrame]; CGRect bounds = [[UIScreen mainScreen] bounds];
self.window = [[LOViewerWindow alloc] initWithFrame:bounds]; self.window = [[LOViewerWindow alloc] initWithFrame:bounds];
theWindow = self.window; theWindow = self.window;
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <UIKit/UIKit.h> #include <UIKit/UIKit.h>
#include <postmac.h> #include <postmac.h>
#include <basebmp/scanlineformats.hxx>
#include "saldatabasic.hxx" #include "saldatabasic.hxx"
#include "headless/svpframe.hxx" #include "headless/svpframe.hxx"
#include "headless/svpgdi.hxx" #include "headless/svpgdi.hxx"
...@@ -284,17 +286,41 @@ bool SvpSalGraphics::CheckContext() ...@@ -284,17 +286,41 @@ bool SvpSalGraphics::CheckContext()
basegfx::B2IVector size = m_aDevice->getSize(); basegfx::B2IVector size = m_aDevice->getSize();
basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer(); basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer();
mrContext = CGBitmapContextCreate(pixelBuffer.get(), size.getX(), size.getY(), 8, m_aDevice->getScanlineStride(), 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() );
CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast);
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" ); 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() CGContextRef SvpSalGraphics::GetContext()
{ {
if (!mrContext) if ( !mrContext )
CheckContext(); CheckContext();
return mrContext; return mrContext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment