[CONFIGURATION]

* NEW: Support for gb.cairo.

[GB.CAIRO]
* NEW: This component allows to use the Cairo library to draw on images.
  Many functions are not implemented yet. Text and Font functions for 
  example.


git-svn-id: svn://localhost/gambas/trunk@1817 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-01-26 12:25:35 +00:00
parent 14d30cdaa7
commit 4f131896d8
34 changed files with 4080 additions and 3425 deletions

View file

@ -1,4 +1,4 @@
SUBDIRS = main @bzlib2_dir@ @zlib_dir@ @mysql_dir@ @odbc_dir@ @postgresql_dir@ @sqlite3_dir@ @sqlite2_dir@ @firebird_dir@ @gtk_dir@ @net_dir@ @curl_dir@ @smtp_dir@ @pcre_dir@ @qt_dir@ @qte_dir@ @kde_dir@ @sdl_dir@ @sdlsound_dir@ @xml_dir@ @v4l_dir@ @crypt_dir@ @opengl_dir@ @corba_dir@ @pdf_dir@ @gtksvg_dir@ @desktop_dir@ @qt4_dir@ comp app help examples
SUBDIRS = main @bzlib2_dir@ @zlib_dir@ @mysql_dir@ @odbc_dir@ @postgresql_dir@ @sqlite3_dir@ @sqlite2_dir@ @firebird_dir@ @gtk_dir@ @net_dir@ @curl_dir@ @smtp_dir@ @pcre_dir@ @qt_dir@ @qte_dir@ @kde_dir@ @sdl_dir@ @sdlsound_dir@ @xml_dir@ @v4l_dir@ @crypt_dir@ @opengl_dir@ @corba_dir@ @pdf_dir@ @gtksvg_dir@ @desktop_dir@ @qt4_dir@ @cairo_dir@ comp app help examples
EXTRA_DIST = component.am README README.*[^~] TODO TEMPLATE reconf reconf-all

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,7 @@ End
Static Private Sub InitComponentNames()
$cName["gb"] = ("Internal native classes")
$cName["gb.cairo"] = ("Cairo graphic library")
$cName["gb.chart"] = ("Chart drawing")
$cName["gb.compress"] = ("Compression & decompression")
$cName["gb.corba"] = ("CORBA Client")
@ -78,8 +79,7 @@ Static Private Sub InitComponentNames()
$cName["gb.gtk.ext"] = ("GTK+ toolkit extension")
$cName["gb.gtk.svg"] = ("GTK+ SVG renderer")
$cName["gb.gui"] = ("QT/GTK+ switcher component")
$cName["gb.image"] = ("Image processing")
$cName["gb.image.info"] = ("Information about image files")
$cName["gb.image"] = ("Image management")
$cName["gb.info"] = ("Information about components")
$cName["gb.ldap"] = ("OpenLDAP client")
$cName["gb.net"] = ("Networking")

View file

@ -36,6 +36,7 @@ GB_CONFIG_SUBDIRS(opengl, gb.opengl)
GB_CONFIG_SUBDIRS(corba, gb.corba)
GB_CONFIG_SUBDIRS(desktop, gb.desktop)
GB_CONFIG_SUBDIRS(qt4, gb.qt4)
GB_CONFIG_SUBDIRS(cairo, gb.cairo)
AC_CONFIG_SUBDIRS(comp)
AC_CONFIG_SUBDIRS(app)

0
gb.cairo/AUTHORS Normal file
View file

1
gb.cairo/COPYING Symbolic link
View file

@ -0,0 +1 @@
../COPYING

0
gb.cairo/ChangeLog Normal file
View file

1
gb.cairo/INSTALL Symbolic link
View file

@ -0,0 +1 @@
../INSTALL

4
gb.cairo/Makefile.am Normal file
View file

@ -0,0 +1,4 @@
SUBDIRS = @CAIRO_DIR@
EXTRA_DIST = reconf gambas.h gb*.h

0
gb.cairo/NEWS Normal file
View file

0
gb.cairo/README Normal file
View file

1
gb.cairo/acinclude.m4 Symbolic link
View file

@ -0,0 +1 @@
../acinclude.m4

1
gb.cairo/component.am Symbolic link
View file

@ -0,0 +1 @@
../component.am

1
gb.cairo/config.guess vendored Symbolic link
View file

@ -0,0 +1 @@
../config.guess

1
gb.cairo/config.sub vendored Symbolic link
View file

@ -0,0 +1 @@
../config.sub

23
gb.cairo/configure.ac Normal file
View file

@ -0,0 +1,23 @@
dnl ---- configure.ac for gb.cairo
AC_INIT(configure.ac)
GB_INIT(gb.cairo)
AC_PROG_LIBTOOL
GB_COMPONENT_PKG_CONFIG(
cairo,
CAIRO,
[Cairo component],
[src],
cairo ">= 1.8.0"
)
GB_COMPONENT_PKG_CONFIG(
cairo_ft,
CAIRO_FT,
[FreeType backend for Cairo],
[src],
cairo-ft ">= 1.8.0"
)
AC_OUTPUT( Makefile src/Makefile )

1
gb.cairo/gambas.h Symbolic link
View file

@ -0,0 +1 @@
../main/share/gambas.h

1
gb.cairo/gb.image.h Symbolic link
View file

@ -0,0 +1 @@
../main/lib/image/gb.image.h

1
gb.cairo/gb_common.h Symbolic link
View file

@ -0,0 +1 @@
../main/share/gb_common.h

1
gb.cairo/ltmain.sh Symbolic link
View file

@ -0,0 +1 @@
../ltmain.sh

1
gb.cairo/reconf Symbolic link
View file

@ -0,0 +1 @@
../reconf

11
gb.cairo/src/Makefile.am Normal file
View file

@ -0,0 +1,11 @@
COMPONENT = gb.cairo
include $(top_srcdir)/component.am
INCLUDES = @CAIRO_INC@
gblib_LTLIBRARIES = gb.cairo.la
gb_cairo_la_LIBADD = @CAIRO_LIB@
gb_cairo_la_LDFLAGS = -module @LD_FLAGS@
gb_cairo_la_SOURCES = main.c main.h c_cairo.c c_cairo.h

579
gb.cairo/src/c_cairo.c Normal file
View file

@ -0,0 +1,579 @@
/***************************************************************************
c_cairo.c
gb.cairo component
(c) 2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#define __C_CAIRO_C
#include "c_cairo.h"
typedef
struct CAIRO_DRAW {
struct CAIRO_DRAW *previous;
void *device;
cairo_surface_t *surface;
cairo_t *context;
CAIRO_PATTERN *pattern;
}
CAIRO_DRAW;
CAIRO_DRAW *_current = NULL;
#define CNT (_current->context)
#define SURFACE (_current->surface)
/***************************************************************************/
#define IMPLEMENT_EXTENTS_PROPERTY(_method, _field) \
BEGIN_PROPERTY(_method) \
GB.ReturnFloat(THIS_EXTENTS->_field); \
END_PROPERTY
IMPLEMENT_EXTENTS_PROPERTY(CAIRO_EXTENTS_x1, x1)
IMPLEMENT_EXTENTS_PROPERTY(CAIRO_EXTENTS_y1, y1)
IMPLEMENT_EXTENTS_PROPERTY(CAIRO_EXTENTS_x2, x2)
IMPLEMENT_EXTENTS_PROPERTY(CAIRO_EXTENTS_y2, y2)
GB_DESC CairoExtentsDesc[] =
{
GB_DECLARE("CairoExtents", sizeof(CAIRO_EXTENTS)),
GB_PROPERTY_READ("X1", "f", CAIRO_EXTENTS_x1),
GB_PROPERTY_READ("Y1", "f", CAIRO_EXTENTS_y1),
GB_PROPERTY_READ("X2", "f", CAIRO_EXTENTS_x2),
GB_PROPERTY_READ("Y2", "f", CAIRO_EXTENTS_y2),
GB_END_DECLARE
};
/***************************************************************************/
BEGIN_METHOD_VOID(CAIRO_PATTERN_free)
cairo_pattern_destroy(THIS_PATTERN->pattern);
END_METHOD
GB_DESC CairoPatternDesc[] =
{
GB_DECLARE("CairoPattern", sizeof(CAIRO_PATTERN)), GB_NOT_CREATABLE(),
GB_METHOD("_free", NULL, CAIRO_PATTERN_free, NULL),
GB_END_DECLARE
};
/***************************************************************************/
static void free_image(GB_IMG *img, void *image)
{
cairo_surface_destroy((cairo_surface_t *)image);
}
static void *temp_image(GB_IMG *img)
{
cairo_surface_t *image;
if (!img->data)
image = NULL; // TODO: use a static small image surface
else
image = cairo_image_surface_create_for_data(img->data, CAIRO_FORMAT_ARGB32, img->width, img->height,
cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, img->width));
return image;
}
static GB_IMG_OWNER _image_owner = {
"gb.cairo",
free_image,
free_image,
temp_image
};
static cairo_surface_t *check_image(void *img)
{
// TODO: format is endian-dependent
return (cairo_surface_t *)IMAGE.Check((GB_IMG *)img, &_image_owner, GB_IMAGE_BGRP);
}
static bool check_device()
{
if (!_current)
{
GB.Error("No current device");
return TRUE;
}
else
return FALSE;
}
#define CHECK_CNT() if (check_device()) return
BEGIN_METHOD(CAIRO_begin, GB_OBJECT device)
void *device = VARG(device);
CAIRO_DRAW *draw;
if (GB.CheckObject(device))
return;
GB.Alloc(POINTER(&draw), sizeof(CAIRO_DRAW));
draw->previous = _current;
if (GB.Is(device, GB.FindClass("Image")))
{
draw->surface = check_image(device);
draw->context = cairo_create(draw->surface);
}
else
{
GB.Free(POINTER(&draw));
GB.Error("Bad device");
return;
}
draw->device = device;
GB.Ref(device);
draw->pattern = NULL;
_current = draw;
END_METHOD
BEGIN_METHOD_VOID(CAIRO_end)
CAIRO_DRAW *draw = _current;
if (check_device())
return;
_current = draw->previous;
cairo_destroy(draw->context);
GB.Free(POINTER(&draw));
END_METHOD
BEGIN_PROPERTY(CAIRO_status)
CHECK_CNT();
GB.ReturnInteger(cairo_status(CNT));
END_PROPERTY
BEGIN_PROPERTY(CAIRO_device)
if (_current)
GB.ReturnObject(_current->device);
else
GB.ReturnNull();
END_PROPERTY
#define IMPLEMENT_METHOD(_method, _api) \
BEGIN_METHOD_VOID(_method) \
CHECK_CNT(); \
_api(CNT); \
END_METHOD
#define IMPLEMENT_METHOD_PRESERVE(_method, _api) \
BEGIN_METHOD(_method, GB_BOOLEAN preserve) \
CHECK_CNT(); \
if (VARGOPT(preserve, FALSE)) \
_api##_preserve(CNT); \
else \
_api(CNT); \
END_METHOD
#define IMPLEMENT_PROPERTY_EXTENTS(_property, _api) \
BEGIN_PROPERTY(_property) \
CAIRO_EXTENTS *extents; \
CHECK_CNT(); \
GB.New(POINTER(&extents), GB.FindClass("CairoExtents"), NULL, NULL); \
_api(CNT, &extents->x1, &extents->y1, &extents->x2, &extents->y2); \
GB.ReturnObject(extents); \
END_METHOD
#define IMPLEMENT_METHOD_IN_X_Y(_method, _api) \
BEGIN_METHOD(_method, GB_FLOAT x; GB_FLOAT y) \
CHECK_CNT(); \
GB.ReturnBoolean(_api(CNT, VARG(x), VARG(y))); \
END_METHOD
IMPLEMENT_METHOD(CAIRO_save, cairo_save)
IMPLEMENT_METHOD(CAIRO_restore, cairo_restore)
IMPLEMENT_METHOD_PRESERVE(CAIRO_clip, cairo_clip)
IMPLEMENT_METHOD(CAIRO_reset_clip, cairo_reset_clip)
IMPLEMENT_PROPERTY_EXTENTS(CAIRO_clip_extents, cairo_clip_extents)
IMPLEMENT_METHOD_PRESERVE(CAIRO_fill, cairo_fill)
IMPLEMENT_PROPERTY_EXTENTS(CAIRO_fill_extents, cairo_fill_extents)
IMPLEMENT_METHOD_IN_X_Y(CAIRO_in_fill, cairo_in_fill)
BEGIN_METHOD(CAIRO_mask, GB_OBJECT pattern)
CAIRO_PATTERN *pattern = (CAIRO_PATTERN *)VARG(pattern);
CHECK_CNT();
if (pattern)
cairo_mask(CNT, pattern->pattern);
END_METHOD
BEGIN_METHOD(CAIRO_paint, GB_FLOAT alpha)
CHECK_CNT();
if (MISSING(alpha))
cairo_paint(CNT);
else
cairo_paint_with_alpha(CNT, VARG(alpha));
END_METHOD
IMPLEMENT_METHOD_PRESERVE(CAIRO_stroke, cairo_stroke)
IMPLEMENT_PROPERTY_EXTENTS(CAIRO_stroke_extents, cairo_stroke_extents)
IMPLEMENT_METHOD_IN_X_Y(CAIRO_in_stroke, cairo_in_stroke)
BEGIN_PROPERTY(CAIRO_source)
CHECK_CNT();
if (READ_PROPERTY)
GB.ReturnObject(_current->pattern);
else
{
CAIRO_PATTERN *old_pattern = _current->pattern;
CAIRO_PATTERN *new_pattern = (CAIRO_PATTERN *)VPROP(GB_OBJECT);
if (new_pattern)
{
GB.Ref(new_pattern);
cairo_set_source(CNT, new_pattern->pattern);
}
GB.Unref(POINTER(&old_pattern));
_current->pattern = new_pattern;
}
END_PROPERTY
BEGIN_PROPERTY(CAIRO_anti_alias)
CHECK_CNT();
if (READ_PROPERTY)
GB.ReturnInteger(cairo_get_antialias(CNT));
else
cairo_set_antialias(CNT, VPROP(GB_INTEGER));
END_PROPERTY
BEGIN_PROPERTY(CAIRO_dash)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_dash_offset)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_fill_rule)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_line_cap)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_line_join)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_line_width)
CHECK_CNT();
if (READ_PROPERTY)
GB.ReturnFloat(cairo_get_line_width(CNT));
else
cairo_set_line_width(CNT, VPROP(GB_FLOAT));
END_PROPERTY
BEGIN_PROPERTY(CAIRO_miter_limit)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_operator)
END_PROPERTY
BEGIN_PROPERTY(CAIRO_tolerance)
END_PROPERTY
IMPLEMENT_METHOD(CAIRO_new_path, cairo_new_path)
IMPLEMENT_METHOD(CAIRO_new_sub_path, cairo_new_sub_path)
IMPLEMENT_METHOD(CAIRO_close_path, cairo_close_path)
BEGIN_METHOD(CAIRO_arc, GB_FLOAT xc; GB_FLOAT yc; GB_FLOAT radius; GB_FLOAT angle1; GB_FLOAT angle2)
CHECK_CNT();
cairo_arc(CNT, VARG(xc), VARG(yc), VARG(radius), VARGOPT(angle1, 0.0), VARGOPT(angle2, M_PI * 2));
END_METHOD
BEGIN_METHOD(CAIRO_arc_negative, GB_FLOAT xc; GB_FLOAT yc; GB_FLOAT radius; GB_FLOAT angle1; GB_FLOAT angle2)
CHECK_CNT();
cairo_arc_negative(CNT, VARG(xc), VARG(yc), VARG(radius), VARGOPT(angle1, 0.0), VARGOPT(angle2, M_PI * 2));
END_METHOD
BEGIN_METHOD(CAIRO_curve_to, GB_FLOAT x1; GB_FLOAT y1; GB_FLOAT x2; GB_FLOAT y2; GB_FLOAT x3; GB_FLOAT y3)
CHECK_CNT();
cairo_curve_to(CNT, VARG(x1), VARG(y1), VARG(x2), VARG(y2), VARG(x3), VARG(y3));
END_METHOD
BEGIN_METHOD(CAIRO_line_to, GB_FLOAT x; GB_FLOAT y)
CHECK_CNT();
cairo_line_to(CNT, VARG(x), VARG(y));
END_METHOD
BEGIN_METHOD(CAIRO_move_to, GB_FLOAT x; GB_FLOAT y)
CHECK_CNT();
cairo_move_to(CNT, VARG(x), VARG(y));
END_METHOD
BEGIN_METHOD(CAIRO_rectangle, GB_FLOAT x; GB_FLOAT y; GB_FLOAT w; GB_FLOAT h)
CHECK_CNT();
cairo_rectangle(CNT, VARG(x), VARG(y), VARG(w), VARG(h));
END_METHOD
BEGIN_METHOD(CAIRO_rel_curve_to, GB_FLOAT x1; GB_FLOAT y1; GB_FLOAT x2; GB_FLOAT y2; GB_FLOAT x3; GB_FLOAT y3)
CHECK_CNT();
cairo_rel_curve_to(CNT, VARG(x1), VARG(y1), VARG(x2), VARG(y2), VARG(x3), VARG(y3));
END_METHOD
BEGIN_METHOD(CAIRO_rel_line_to, GB_FLOAT x; GB_FLOAT y)
CHECK_CNT();
cairo_rel_line_to(CNT, VARG(x), VARG(y));
END_METHOD
BEGIN_METHOD(CAIRO_rel_move_to, GB_FLOAT x; GB_FLOAT y)
CHECK_CNT();
cairo_rel_move_to(CNT, VARG(x), VARG(y));
END_METHOD
IMPLEMENT_PROPERTY_EXTENTS(CAIRO_path_extents, cairo_path_extents)
static void make_pattern(cairo_pattern_t *pattern)
{
CAIRO_PATTERN *pat;
GB.New(POINTER(&pat), GB.FindClass("CairoPattern"), NULL, NULL);
pat->pattern = pattern;
GB.ReturnObject(pat);
}
BEGIN_METHOD(CAIRO_solid_pattern, GB_FLOAT r; GB_FLOAT g; GB_FLOAT b; GB_FLOAT a)
cairo_pattern_t *pattern;
if (MISSING(a))
pattern = cairo_pattern_create_rgb(VARG(r), VARG(g), VARG(b));
else
pattern = cairo_pattern_create_rgba(VARG(r), VARG(g), VARG(b), VARG(a));
make_pattern(pattern);
END_METHOD
BEGIN_METHOD(CAIRO_image_pattern, GB_OBJECT image; GB_FLOAT x; GB_FLOAT y; GB_INTEGER extend; GB_INTEGER filter)
cairo_surface_t *surface;
cairo_pattern_t *pattern;
surface = check_image((GB_IMG *)VARG(image));
if (!surface)
{
GB.Error("Null image");
return;
}
pattern = cairo_pattern_create_for_surface(surface);
if (!MISSING(x) || !MISSING(y))
{
cairo_matrix_t matrix;
cairo_matrix_init_translate (&matrix, -VARGOPT(x, 0.0), -VARGOPT(y, 0.0));
cairo_pattern_set_matrix (pattern, &matrix);
}
if (!MISSING(extend))
cairo_pattern_set_extend(pattern, VARG(extend));
if (!MISSING(filter))
cairo_pattern_set_filter(pattern, VARG(filter));
make_pattern(pattern);
END_METHOD
BEGIN_METHOD(CAIRO_linear_gradient_pattern, GB_FLOAT x0; GB_FLOAT y0; GB_FLOAT x1; GB_FLOAT y1; GB_OBJECT colors)
END_METHOD
BEGIN_METHOD(CAIRO_radial_gradient_pattern, GB_FLOAT cx0; GB_FLOAT cy0; GB_FLOAT radius0; GB_FLOAT cx1; GB_FLOAT cy1; GB_FLOAT radius1; GB_OBJECT colors)
END_METHOD
GB_DESC CairoDesc[] =
{
GB_DECLARE("Cairo", 0), GB_VIRTUAL_CLASS(),
GB_CONSTANT("StatusSuccess", "i", CAIRO_STATUS_SUCCESS),
GB_CONSTANT("StatusNoMemory", "i", CAIRO_STATUS_NO_MEMORY),
GB_CONSTANT("StatusInvalidRestore", "i", CAIRO_STATUS_INVALID_RESTORE),
GB_CONSTANT("StatusInvalidPopGroup", "i", CAIRO_STATUS_INVALID_POP_GROUP),
GB_CONSTANT("StatusNoCurrentPoint", "i", CAIRO_STATUS_NO_CURRENT_POINT),
GB_CONSTANT("StatusInvalidMatrix", "i", CAIRO_STATUS_INVALID_MATRIX),
GB_CONSTANT("StatusInvalidStatus", "i", CAIRO_STATUS_INVALID_STATUS),
GB_CONSTANT("StatusNullPointer", "i", CAIRO_STATUS_NULL_POINTER),
GB_CONSTANT("StatusInvalidString", "i", CAIRO_STATUS_INVALID_STRING),
GB_CONSTANT("StatusInvalidPathData", "i", CAIRO_STATUS_INVALID_PATH_DATA),
GB_CONSTANT("StatusReadError", "i", CAIRO_STATUS_READ_ERROR),
GB_CONSTANT("StatusWriteError", "i", CAIRO_STATUS_WRITE_ERROR),
GB_CONSTANT("StatusSurfaceFinished", "i", CAIRO_STATUS_SURFACE_FINISHED),
GB_CONSTANT("StatusSurfaceTypeMismatch", "i", CAIRO_STATUS_SURFACE_TYPE_MISMATCH),
GB_CONSTANT("StatusPatternTypeMismatch", "i", CAIRO_STATUS_PATTERN_TYPE_MISMATCH),
GB_CONSTANT("StatusInvalidContent", "i", CAIRO_STATUS_INVALID_CONTENT),
GB_CONSTANT("StatusInvalidFormat", "i", CAIRO_STATUS_INVALID_FORMAT),
GB_CONSTANT("StatusInvalidVisual", "i", CAIRO_STATUS_INVALID_VISUAL),
GB_CONSTANT("StatusFileNotFound", "i", CAIRO_STATUS_FILE_NOT_FOUND),
GB_CONSTANT("StatusInvalidDash", "i", CAIRO_STATUS_INVALID_DASH),
GB_CONSTANT("StatusInvalidDscComment", "i", CAIRO_STATUS_INVALID_DSC_COMMENT),
GB_CONSTANT("StatusInvalidIndex", "i", CAIRO_STATUS_INVALID_INDEX),
GB_CONSTANT("StatusClipNotRepresentable", "i", CAIRO_STATUS_CLIP_NOT_REPRESENTABLE),
GB_CONSTANT("StatusTempFileError", "i", CAIRO_STATUS_TEMP_FILE_ERROR),
GB_CONSTANT("StatusInvalidStride", "i", CAIRO_STATUS_INVALID_STRIDE),
GB_CONSTANT("StatusFontTypeMismatch", "i", CAIRO_STATUS_FONT_TYPE_MISMATCH),
GB_CONSTANT("StatusUserFontImmutable", "i", CAIRO_STATUS_USER_FONT_IMMUTABLE),
GB_CONSTANT("StatusUserFontError", "i", CAIRO_STATUS_USER_FONT_ERROR),
GB_CONSTANT("StatusNegativeCount", "i", CAIRO_STATUS_NEGATIVE_COUNT),
GB_CONSTANT("StatusInvalidClusters", "i", CAIRO_STATUS_INVALID_CLUSTERS),
GB_CONSTANT("StatusInvalidSlant", "i", CAIRO_STATUS_INVALID_SLANT),
GB_CONSTANT("StatusInvalidWeight", "i", CAIRO_STATUS_INVALID_WEIGHT),
GB_CONSTANT("AntiAliasDefault", "i", CAIRO_ANTIALIAS_DEFAULT),
GB_CONSTANT("AntiAliasNone", "i", CAIRO_ANTIALIAS_NONE),
GB_CONSTANT("AntiAliasGray", "i", CAIRO_ANTIALIAS_GRAY),
GB_CONSTANT("AntiAliasSubPixel", "i", CAIRO_ANTIALIAS_SUBPIXEL),
GB_CONSTANT("ExtendNone", "i", CAIRO_EXTEND_NONE),
GB_CONSTANT("ExtendRepeat", "i", CAIRO_EXTEND_REPEAT),
GB_CONSTANT("ExtendReflect", "i", CAIRO_EXTEND_REFLECT),
GB_CONSTANT("ExtendPad", "i", CAIRO_EXTEND_PAD),
GB_CONSTANT("FilterFast", "i", CAIRO_FILTER_FAST),
GB_CONSTANT("FilterGood", "i", CAIRO_FILTER_GOOD),
GB_CONSTANT("FilterBest", "i", CAIRO_FILTER_BEST),
GB_CONSTANT("FilterNearest", "i", CAIRO_FILTER_NEAREST),
GB_CONSTANT("FilterBilinear", "i", CAIRO_FILTER_BILINEAR),
GB_CONSTANT("FilterGaussian", "i", CAIRO_FILTER_GAUSSIAN),
GB_STATIC_METHOD("Begin", NULL, CAIRO_begin, "(Device)o"),
GB_STATIC_METHOD("End", NULL, CAIRO_end, NULL),
GB_STATIC_PROPERTY_READ("Status", "s", CAIRO_status),
GB_STATIC_PROPERTY_READ("Device", "o", CAIRO_device),
GB_STATIC_METHOD("Save", NULL, CAIRO_save, NULL),
GB_STATIC_METHOD("Restore", NULL, CAIRO_save, NULL),
GB_STATIC_METHOD("Clip", NULL, CAIRO_clip, "[(Preserve)b]"),
GB_STATIC_METHOD("ResetClip", NULL, CAIRO_reset_clip, NULL),
GB_STATIC_PROPERTY_READ("ClipExtents", "Float[]", CAIRO_clip_extents),
GB_STATIC_METHOD("Fill", NULL, CAIRO_fill, "[(Preserve)b]"),
GB_STATIC_PROPERTY_READ("FillExtents", "Float[]", CAIRO_fill_extents),
GB_STATIC_METHOD("InFill", "b", CAIRO_in_fill, "(X)f(Y)f"),
GB_STATIC_METHOD("Mask", NULL, CAIRO_mask, "(Pattern)CairoPattern;"),
GB_STATIC_METHOD("Paint", NULL, CAIRO_paint, "[(Alpha)f]"),
GB_STATIC_METHOD("Stroke", NULL, CAIRO_stroke, "[(Preserve)b]"),
GB_STATIC_PROPERTY_READ("StrokeExtents", "Float[]", CAIRO_stroke_extents),
GB_STATIC_METHOD("InStroke", "b", CAIRO_in_stroke, "(X)f(Y)f"),
GB_STATIC_PROPERTY("Source", "CairoPattern", CAIRO_source),
GB_STATIC_PROPERTY("AntiAlias", "i", CAIRO_anti_alias),
GB_STATIC_PROPERTY("Dash", "Float[]", CAIRO_dash),
GB_STATIC_PROPERTY("DashOffset", "f", CAIRO_dash_offset),
GB_STATIC_PROPERTY("FillRule", "i", CAIRO_fill_rule),
GB_STATIC_PROPERTY("LineCap", "i", CAIRO_line_cap),
GB_STATIC_PROPERTY("LineJoin", "i", CAIRO_line_join),
GB_STATIC_PROPERTY("LineWidth", "f", CAIRO_line_width),
GB_STATIC_PROPERTY("MiterLimit", "f", CAIRO_miter_limit),
GB_STATIC_PROPERTY("Operator", "i", CAIRO_operator),
GB_STATIC_PROPERTY("Tolerance", "f", CAIRO_tolerance),
GB_STATIC_METHOD("NewPath", NULL, CAIRO_new_path, NULL),
GB_STATIC_METHOD("NewSubPath", NULL, CAIRO_new_sub_path, NULL),
GB_STATIC_METHOD("ClosePath", NULL, CAIRO_close_path, NULL),
GB_STATIC_METHOD("Arc", NULL, CAIRO_arc, "(XC)f(YC)f(Radius)f[(Angle1)f(Angle2)f]"),
GB_STATIC_METHOD("ArcNegative", NULL, CAIRO_arc_negative, "(XC)f(YC)f(Radius)f[(Angle1)f(Angle2)f]"),
GB_STATIC_METHOD("CurveTo", NULL, CAIRO_curve_to, "(X1)f(Y1)f(X2)f(Y2)f(X3)f(Y3)f"),
GB_STATIC_METHOD("LineTo", NULL, CAIRO_line_to, "(X)f(Y)f"),
GB_STATIC_METHOD("MoveTo", NULL, CAIRO_move_to, "(X)f(Y)f"),
GB_STATIC_METHOD("Rectangle", NULL, CAIRO_rectangle, "(X)f(Y)f(Width)f(Height)f"),
GB_STATIC_METHOD("RelCurveTo", NULL, CAIRO_rel_curve_to, "(DX1)f(DY1)f(DX2)f(DY2)f(DX3)f(DY3)f"),
GB_STATIC_METHOD("RelLineTo", NULL, CAIRO_rel_line_to, "(DX)f(DY)f"),
GB_STATIC_METHOD("RelMoveTo", NULL, CAIRO_rel_move_to, "(DX)f(DY)f"),
GB_STATIC_PROPERTY_READ("PathExtents", "Float[]", CAIRO_path_extents),
GB_STATIC_METHOD("SolidPattern", "CairoPattern", CAIRO_solid_pattern, "(Red)f(Green)f(Blue)f[(Alpha)f]"),
GB_STATIC_METHOD("ImagePattern", "CairoPattern", CAIRO_image_pattern, "(Image)Image;[(X)f(Y)f(Extend)i(Filter)i]"),
GB_STATIC_METHOD("LinearGradient", "CairoPattern", CAIRO_linear_gradient_pattern, "(X0)f(Y0)f(X1)f(Y1)f(Colors)Float[][];"),
GB_STATIC_METHOD("RadialGradient", "CairoPattern", CAIRO_radial_gradient_pattern, "(CX0)f(CY0)f(Radius0)f(CX1)f(CY1)f(Radius1)f(Colors)Float[][];"),
//GB_METHOD("SetSourceRGB", NULL, CAIRO_set_source_rgb, "(Red)f(Green)f(Blue)f[(Alpha)f]"),
GB_END_DECLARE
};

57
gb.cairo/src/c_cairo.h Normal file
View file

@ -0,0 +1,57 @@
/***************************************************************************
c_cairo.h
gb.cairo component
(c) 2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#ifndef __C_CAIRO_H
#define __C_CAIRO_H
#include "main.h"
#ifndef __C_CAIRO_C
extern GB_DESC CairoExtentsDesc[];
extern GB_DESC CairoPatternDesc[];
extern GB_DESC CairoDesc[];
#else
#define THIS_EXTENTS ((CAIRO_EXTENTS *)_object)
#define THIS_PATTERN ((CAIRO_PATTERN *)_object)
#endif
typedef
struct {
GB_BASE ob;
double x1, y1, x2, y2;
}
CAIRO_EXTENTS;
typedef
struct {
GB_BASE ob;
cairo_pattern_t *pattern;
}
CAIRO_PATTERN;
#endif

View file

@ -0,0 +1,4 @@
[Component]
Key=gb.cairo
Author=Benoît Minisini
State=2

49
gb.cairo/src/main.c Normal file
View file

@ -0,0 +1,49 @@
/***************************************************************************
main.c
gb.cairo component
(c) 2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#define __MAIN_C
#include "main.h"
#include "c_cairo.h"
GB_INTERFACE GB EXPORT;
IMAGE_INTERFACE IMAGE EXPORT;
GB_DESC *GB_CLASSES[] EXPORT =
{
CairoPatternDesc,
CairoExtentsDesc,
CairoDesc,
NULL
};
int EXPORT GB_INIT(void)
{
GB.GetInterface("gb.image", IMAGE_INTERFACE_VERSION, &IMAGE);
return FALSE;
}
void EXPORT GB_EXIT()
{
}

38
gb.cairo/src/main.h Normal file
View file

@ -0,0 +1,38 @@
/***************************************************************************
main.h
gb.cairo component
(c) 2009 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#ifndef __MAIN_H
#define __MAIN_H
#include "gambas.h"
#include "gb.image.h"
#include "gb_common.h"
#include <cairo.h>
#ifndef __MAIN_C
extern GB_INTERFACE GB;
extern IMAGE_INTERFACE IMAGE;
#endif
#endif /* __MAIN_H */

View file

@ -8,6 +8,7 @@ Name[tr]=GTK+ grafiksel bileşenleri
Author=Daniel Campos Fernández,Benoît Minisini
Type=Form
Implements=Form,EventLoop,ImageProvider
Requires=gb.image
[Form]
Control=Label,TextLabel,Separator,PictureBox,MovieBox,ProgressBar

View file

@ -3,6 +3,7 @@ Key=gb.qt
Author=Benoît Minisini
Implements=Form,EventLoop,ImageProvider
Type=Form
Requires=gb.image
[Form]
Control=Label,TextLabel,Separator,PictureBox,MovieBox,ProgressBar

View file

@ -875,7 +875,7 @@ static void myMessageHandler(QtMsgType type, const char *msg )
}
#endif
const char *GB_INCLUDE EXPORT = "gb.draw,gb.image";
const char *GB_INCLUDE EXPORT = "gb.draw";
int EXPORT GB_INIT(void)
{

View file

@ -6,4 +6,5 @@ Name[pl]=Biblioteka dźwięku na SDL
Name[tr]=SDL tabanlı kitaplık
Author=Laurent Carlier
Implements=EventLoop,ImageProvider,OpenGLViewer
Requires=gb.image
State=1

View file

@ -26,7 +26,7 @@
#include "image.h"
#include "CImage.h"
BEGIN_METHOD(CIMAGE_new, GB_INTEGER w; GB_INTEGER h; GB_INTEGER format; GB_INTEGER col)
BEGIN_METHOD(CIMAGE_new, GB_INTEGER w; GB_INTEGER h; GB_INTEGER col; GB_INTEGER format)
int format = IMAGE_get_default_format();
@ -119,7 +119,7 @@ GB_DESC CImageDesc[] =
GB_CONSTANT("Standard", "i", 0),
GB_CONSTANT("Premultiplied", "i", 1),
GB_METHOD("_new", NULL, CIMAGE_new, "[(Width)i(Height)i(Format)i(Color)i]"),
GB_METHOD("_new", NULL, CIMAGE_new, "[(Width)i(Height)i(Color)i(Format)i]"),
GB_METHOD("_free", NULL, CIMAGE_free, NULL),
GB_METHOD("_get", "i", CIMAGE_get, "(X)i(Y)i"),

View file

@ -335,15 +335,17 @@ static void IMAGE_convert(GB_IMG *img, int format)
img->format = format;
GB.Alloc(POINTER(&data), IMAGE_size(img));
convert_image(data, format, img->data, img->format, img->width, img->height);
GB.Free(POINTER(&img->data));
img->data = data;
//GB.Free(POINTER(&img->data));
IMAGE_take(img, &_image_owner, NULL, img->width, img->height, data);
}
// Check if a temporary handle is needed, and create it if needed by calling the owner "temp" function
void *IMAGE_check(GB_IMG *img, GB_IMG_OWNER *temp_owner, int format)
{
if (!img)
return NULL;
// If we already have the temporary handle, then do nothing
if (img->temp_owner == temp_owner)
return img->temp_handle;
@ -358,8 +360,6 @@ void *IMAGE_check(GB_IMG *img, GB_IMG_OWNER *temp_owner, int format)
}
// Get the temporary handle
img->temp_owner = temp_owner;
if (temp_owner)
{
// If we are the owner, we must use our owner handle as temporary handle
@ -368,11 +368,15 @@ void *IMAGE_check(GB_IMG *img, GB_IMG_OWNER *temp_owner, int format)
// If we are not the owner, then we will have to create the temporary handle ourself
else
{
// Conversion can make gb.image the new owner and temporary owner
IMAGE_convert(img, format);
img->temp_handle = (*img->temp_owner->temp)(img);
img->temp_handle = (*temp_owner->temp)(img);
}
}
// Become the temporary owner
img->temp_owner = temp_owner;
return img->temp_handle;
}
@ -380,6 +384,9 @@ void *IMAGE_check(GB_IMG *img, GB_IMG_OWNER *temp_owner, int format)
void IMAGE_take(GB_IMG *img, GB_IMG_OWNER *owner, void *owner_handle, int width, int height, unsigned char *data)
{
if (!img)
return;
// If we are already the owner with the same handle, then do nothing
if (img->owner == owner && img->owner_handle == owner_handle)
return;