View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002171 | Scribus | Internal | public | 2005-07-02 14:32 | 2005-07-06 04:42 |
Reporter | jghali | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Windows | OS | Windows | OS Version | 2000 SP4 |
Product Version | 1.3.0cvs | ||||
Fixed in Version | 1.3.0cvs | ||||
Summary | 0002171: Win32-based implementation for ScPainter | ||||
Description | Here is a patch which implements ScPainter using Win32 GDI functions. | ||||
Tags | No tags attached. | ||||
Patch | |||||
2005-07-02 14:32
|
scpainter_win32.diff (3,530 bytes)
Index: scpainter.cpp =================================================================== RCS file: /cvs/Scribus/scribus/scpainter.cpp,v retrieving revision 1.19.2.10 diff -u -r1.19.2.10 scpainter.cpp --- scpainter.cpp 22 Apr 2005 22:41:57 -0000 1.19.2.10 +++ scpainter.cpp 2 Jul 2005 16:12:43 -0000 @@ -58,6 +58,10 @@ #include <pixbuf/gdk-pixbuf-xlibrgb.h> #endif +#if defined(_WIN32) && defined(SC_USE_GDI) +#include <windows.h> +#endif + #include <math.h> #include "art_kmisc.h" @@ -98,6 +102,8 @@ #if defined(Q_WS_X11) && defined(SC_USE_PIXBUF) xlib_rgb_init_with_depth( target->x11Display(), XScreenOfDisplay( target->x11Display(), target->x11Screen() ), target->x11Depth() ); gc = XCreateGC( target->x11Display(), target->handle(), 0, 0 ); +#elif defined(_WIN32) && defined(SC_USE_GDI) + dc = CreateCompatibleDC( target->handle() ); #endif } @@ -148,6 +154,9 @@ #if defined(Q_WS_X11) && defined(SC_USE_PIXBUF) if( gc ) XFreeGC( m_target->x11Display(), gc ); +#elif defined(_WIN32) && defined(SC_USE_GDI) + if( dc ) + DeleteDC( dc ); #endif } @@ -191,6 +200,43 @@ #if defined(Q_WS_X11) && defined(SC_USE_PIXBUF) // Use the original gdk-pixbuf based bitblit on X11 xlib_draw_rgb_32_image( m_target->handle(), gc, m_x, m_y, m_width, m_height, XLIB_RGB_DITHER_NONE, m_buffer, m_width * 4 ); +#elif defined(_WIN32) && defined(SC_USE_GDI) + // Use Win32 implementation + BITMAPINFO bmpInfo; + BITMAPINFOHEADER *bmpHeader; + long* bmpData; + + bmpHeader = &(bmpInfo.bmiHeader); + bmpHeader->biSize = sizeof(BITMAPINFOHEADER); + bmpHeader->biWidth = m_width; + bmpHeader->biHeight = -m_height; + bmpHeader->biPlanes = 1; + bmpHeader->biBitCount = 32; + bmpHeader->biCompression = BI_RGB; + bmpHeader->biSizeImage = 0; // Valid only if biCompression = BI_RGB + bmpHeader->biXPelsPerMeter = 0; + bmpHeader->biYPelsPerMeter = 0; + bmpHeader->biClrUsed = 0; + bmpHeader->biClrImportant = 0; + + // Create a device independent Bitmap + HBITMAP hBmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, (void** ) (&bmpData), NULL, NULL); + art_u8 * p = m_buffer; + art_u8 r, g, b, a; + int words = m_width * m_height; // Valid only if biBitCount = 32 + + for (int i = 0; i < words; ++i) { + r = *p++; + g = *p++; + b = *p++; + a = *p++; + *bmpData++ = ( (a << 24) + (r << 16) + (g << 8) + b); + } + + HGDIOBJ obj = SelectObject( dc, hBmp); + BitBlt( m_target->handle() , m_x, m_y, m_width, m_height, dc, 0, 0, SRCCOPY); + SelectObject( dc, obj); + DeleteObject( hBmp ); #else // Portable copying onto the canvas with no X11 dependency by Andreas Vox QImage qimg(m_width, m_height, 32, QImage::BigEndian); Index: scpainter.h =================================================================== RCS file: /cvs/Scribus/scribus/scpainter.h,v retrieving revision 1.7.2.7 diff -u -r1.7.2.7 scpainter.h --- scpainter.h 22 Apr 2005 22:41:57 -0000 1.7.2.7 +++ scpainter.h 2 Jul 2005 16:09:30 -0000 @@ -40,6 +40,12 @@ #define SC_USE_PIXBUF #endif +// If defined, use Win32 GDI functions for ScPainter::end() on Win32 (ignored +// on other platforms). Otherwise use portable ScPainter::end() +#ifndef SC_USE_GDI +#define SC_USE_GDI +#endif + class QPainter; struct _ArtVpath; struct _ArtBpath; @@ -169,6 +175,8 @@ bool imageMode; #if defined(Q_WS_X11) && defined(SC_USE_PIXBUF) GC gc; +#elif defined(_WIN32) && defined(SC_USE_GDI) + HDC dc; #endif }; |
|
Sorry this is taking so long; things got unexpectedly busy. I'll see if I can check this out tomorrow. |
|
Dont' worry, I fully understand. |
|
Looks good. Applied and checked in. Thanks. |
Date Modified | Username | Field | Change |
---|---|---|---|
2005-07-02 14:32 | jghali | New Issue | |
2005-07-02 14:32 | jghali | File Added: scpainter_win32.diff | |
2005-07-02 17:16 | cbradney | Relationship added | has duplicate 0002172 |
2005-07-03 14:13 |
|
Status | new => assigned |
2005-07-03 14:13 |
|
Assigned To | => ringerc |
2005-07-04 16:03 |
|
Note Added: 0005385 | |
2005-07-04 16:16 | jghali | Note Added: 0005386 | |
2005-07-05 03:42 |
|
Status | assigned => resolved |
2005-07-05 03:42 |
|
Resolution | open => fixed |
2005-07-05 03:42 |
|
Note Added: 0005390 | |
2005-07-05 09:31 | cbradney | Status | resolved => closed |
2005-07-05 09:31 | cbradney | Fixed in Version | => 1.3.0cvs |
2005-07-06 04:42 |
|
Relationship added | child of 0000015 |