|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Simple Win32 GDI example with Cairo wantedHi,
I was able to build Cairo on Windows and also got a simple sample application, that renders to a PNG. #define LIBCAIRO_EXPORTS #include <cairo.h> int _tmain(int argc, _TCHAR* argv[]) { cairo_surface_t *surface; cairo_t *cr; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80); cr = cairo_create (surface); cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, 32.0); cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); cairo_move_to (cr, 10.0, 50.0); cairo_show_text (cr, "Hello, World"); cairo_destroy (cr); cairo_surface_write_to_png (surface, "hello.png"); cairo_surface_destroy (surface); return 0; } Does anyone has an example, that does that simple rendering to a window not using GTK but to a Windows MFC window. Any pointer or example or even a VisualStudio project would be creately appreciated. Thanks, Stefan _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Simple Win32 GDI example with Cairo wantedStefan,
CWnd *pWnd; // we assume pWnd is pointing to your window HDC hDC = GetDC(pWnd->m_hWnd); // get DC from window handle cairo_surface_t * pSurface = cairo_win32_surface_create(hDC); cairo_t * pCairo = cairo_create(pSurface); that should do it. Markus. -----Original Message----- From: cairo-bounces@... [mailto:cairo-bounces@...] On Behalf Of Stefan Landvogt Sent: Thursday, August 28, 2008 16:40 To: cairo@... Subject: [cairo] Simple Win32 GDI example with Cairo wanted Hi, I was able to build Cairo on Windows and also got a simple sample application, that renders to a PNG. #define LIBCAIRO_EXPORTS #include <cairo.h> int _tmain(int argc, _TCHAR* argv[]) { cairo_surface_t *surface; cairo_t *cr; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80); cr = cairo_create (surface); cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, 32.0); cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); cairo_move_to (cr, 10.0, 50.0); cairo_show_text (cr, "Hello, World"); cairo_destroy (cr); cairo_surface_write_to_png (surface, "hello.png"); cairo_surface_destroy (surface); return 0; } Does anyone has an example, that does that simple rendering to a window not using GTK but to a Windows MFC window. Any pointer or example or even a VisualStudio project would be creately appreciated. Thanks, Stefan _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Hello, Cairo! Re: Simple Win32 GDI example with Cairo wantedI would second this. Although setting up a "Hello world" IDE project drawing the text using Cairo should not be a Big Deal, it certainly would help the initial step (instead of pressing 'new' in the IDE). Especially since Windows is my 3rd platform, and I am using VC++ 2008 Express only occasionally. So, if anyone has a "Hello world" Cairo + VC++ 2008 project to spare, thanks! :) In fact, I would like to see such Hello World for VC++, GTK+ and OS X (XCode) all of them. -asko Stefan Landvogt kirjoitti 29.8.2008 kello 0:40: > Hi, > > I was able to build Cairo on Windows and also got a simple sample > application, that renders to a PNG. > > #define LIBCAIRO_EXPORTS > > #include <cairo.h> > > int _tmain(int argc, _TCHAR* argv[]) > { > cairo_surface_t *surface; > cairo_t *cr; > > surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80); > cr = cairo_create (surface); > > cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, > CAIRO_FONT_WEIGHT_BOLD); > cairo_set_font_size (cr, 32.0); > cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); > cairo_move_to (cr, 10.0, 50.0); > cairo_show_text (cr, "Hello, World"); > cairo_destroy (cr); > cairo_surface_write_to_png (surface, "hello.png"); > cairo_surface_destroy (surface); > > return 0; > } > > Does anyone has an example, that does that simple rendering to a > window not using GTK but to a Windows MFC window. Any pointer or > example or even a VisualStudio project would be creately appreciated. > > Thanks, > Stefan > _______________________________________________ > cairo mailing list > cairo@... > http://lists.cairographics.org/mailman/listinfo/cairo _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Hello, Cairo! Re: Simple Win32 GDI example with Cairo wantedAsko Kauppi wrote:
> I would second this. > > Although setting up a "Hello world" IDE project drawing the text using > Cairo should not be a Big Deal, it certainly would help the initial > step (instead of pressing 'new' in the IDE). > > Especially since Windows is my 3rd platform, and I am using VC++ 2008 > Express only occasionally. So, if anyone has a "Hello world" Cairo + > VC++ 2008 project to spare, thanks! :) > > In fact, I would like to see such Hello World for VC++, GTK+ and OS X > (XCode) all of them. > > -asko > currently free version of C++ Builder) - I'm a bit busy the next few days, but should be able to post more information about it in the weekend. Cheers, Mohit. 9/2/2008 | 12:24 AM. _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Hello, Cairo! Re: Simple Win32 GDI example with Cairo wantedHi folks,
I setup VS2008 Cairo hello world project without using GTK+ for windows. Actually Cairo has win32 surface support(base on GDI). Use cairo_win32_surface_create
instead of other surface creating API (like cairo_image_surface_create).
Only few instructions need to be follow: 0. Download cairo lib for windows. 1. Use wizard to create a win32 project in Visual C++ 2008 express. 2. Open <your project name>.cpp and find function WndProc.
3. Modify WM_PAINT branch with piece of code below: case WM_PAINT: hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here... cairo_surface_t *surface; cairo_t *cr;
surface = cairo_win32_surface_create(hdc); cr = cairo_create(surface);
Draw(cr); // <<<<<<Cairo draw here cairo_destroy(cr); EndPaint(hWnd, &ps); break;
4. Add cairo lib path to new project. 5.Compile and check the result After that, you will see your cairo drawing in Windows program's client area.
Hope it is helpful, and correct me if there are mistakes. 2008/9/2 Mohit Sindhwani <tech@...>
_______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Hello, Cairo! Re: Simple Win32 GDI example with Cairo wantedWhich precompiled Cairo lib did you use? The only one I've found is the one referenced at cairographics.org (http://inkscape.modevia.com/win32libs ). That has cairo-1.6.4-mingw.tar.gz that seems to be MSYS-based (has bin/ libcairo-2.dll, lib/libcairo.la, lib/libcairo.dll.a). These are useless from VC++, right? -asko ja alex kirjoitti 3.9.2008 kello 14:31: > Hi folks, > I setup VS2008 Cairo hello world project without using GTK+ for > windows. > > Actually Cairo has win32 surface support(base on GDI). Use > cairo_win32_surface_create > > instead of other surface creating API (like > cairo_image_surface_create). > > Only few instructions need to be follow: > 0. Download cairo lib for windows. > 1. Use wizard to create a win32 project in Visual C++ 2008 express. > 2. Open <your project name>.cpp and find function WndProc. > 3. Modify WM_PAINT branch with piece of code below: > case WM_PAINT: > hdc = BeginPaint(hWnd, &ps); > // TODO: Add any drawing code here... > cairo_surface_t *surface; > cairo_t *cr; > > surface = cairo_win32_surface_create(hdc); > cr = cairo_create(surface); > Draw(cr); // <<<<<<Cairo draw here > cairo_destroy(cr); > > EndPaint(hWnd, &ps); > break; > 4. Add cairo lib path to new project. > 5.Compile and check the result > > After that, you will see your cairo drawing in Windows program's > client area. > > Hope it is helpful, and correct me if there are mistakes. > > > 2008/9/2 Mohit Sindhwani <tech@...> > Asko Kauppi wrote: > > I would second this. > > > > Although setting up a "Hello world" IDE project drawing the text > using > > Cairo should not be a Big Deal, it certainly would help the initial > > step (instead of pressing 'new' in the IDE). > > > > Especially since Windows is my 3rd platform, and I am using VC++ > 2008 > > Express only occasionally. So, if anyone has a "Hello world" > Cairo + > > VC++ 2008 project to spare, thanks! :) > > > > In fact, I would like to see such Hello World for VC++, GTK+ and > OS X > > (XCode) all of them. > > > > -asko > > > Actually I have a Hello World example for Borland Turbo C++ (the new > currently free version of C++ Builder) - I'm a bit busy the next few > days, but should be able to post more information about it in the > weekend. > > Cheers, > Mohit. > 9/2/2008 | 12:24 AM. > > _______________________________________________ > cairo mailing list > cairo@... > http://lists.cairographics.org/mailman/listinfo/cairo > > _______________________________________________ > cairo mailing list > cairo@... > http://lists.cairographics.org/mailman/listinfo/cairo _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Hello, Cairo! Re: Simple Win32 GDI example with Cairo wanted> The only one I've found is the one referenced at cairographics.org (http://inkscape.modevia.com/win32libs).
There are also precompiled Win32 cairo binaries (built by me) at http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/cairo-1.6.4-2.zip (runtime files) and http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/cairo-dev-1.6.4-2.zip (developer files). This developer package contains also a .lib format import library. (Although as such, import libraries for C APIs should be compatible between mingw and MSVC, one should be able to copy a .dll.a file to a .lib file or vice versa. At least, in theory. I haven't verified this recently.) I don't know what the difference beween the Inkscape cairo build and mine is. They might differ in surface backends provided, for instance, or in how they link to external libraries. Mine requires the libpng-1.2.29 runtime (libpng12-0.dll) and zlib-1.2.3 runtime (zlib1.dll), both available in the same folder. (The zlib is jus a repackaging of the official zlib DLL.) > That has cairo-1.6.4-mingw.tar.gz that seems to be MSYS-based "MSYS-based" is misleading. The organisation of the files is Unix-inspired, yes. And MSYS is the preferred Unix-like development environment to use when using mingw (i.e. gcc and the GNU toolchain) on Windows. But the run-time files, i.e. the DLL, in the above-mentioned packages can be used without any MSYS present. And also the developer files, i.e. headers and import libraries, can be used without any MSYS present. > (has bin/libcairo-2.dll, lib/libcairo.la, lib/libcairo.dll.a). These are > useless from VC++, right? The .la file is mostly useless in all cases, IMHO .la files should never be distributed. The DLL should be usable very nicely from MSVC-compiled code as the cairo API is plain C and passes no references to data (like file descriptors) that would be specific to the C runtime used (my cairo DLL uses msvcrt.dll, and code built by recent MSVS versions use compiler version specific C runtimes). And as I said, in theory it should be possible to just copy the libcairo.dll.a import library to a cairo.lib. Or more reliably, use some suitable tool (pexports or link -dump -exports) to list the entry points in the DLL, edit that into a .def file, and generate the import library with lib.exe yourself. Or just use the import library from my developer package. --tml _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
| Free embeddable forum powered by Nabble | Forum Help |