Added scaling functions into gtk-doc framework.

2000-01-05  Owen Taylor  <otaylor@redhat.com>

	* doc/Makefile.am doc/gdk-pixbuf-sections.txt
	  doc/gdk-pixbuf.sgml doc/tmpl/scaling.sgml:
	Added scaling functions into gtk-doc framework.

	* gdk-pixbuf/gdk-pixbuf-scale.c: Documentation fixes.

	* gdk-pixbuf/testpixbuf-scale.c (expose_cb): Simplify a bit.

	* gdk-pixbuf/pixops/pixops.c (pixops_composite_color): Return
	immediately if scale_x or scale_y is 0.
This commit is contained in:
Owen Taylor 2000-01-06 01:08:10 +00:00 committed by Owen Taylor
parent bba95de158
commit 65de04cdb8
15 changed files with 328 additions and 82 deletions

View File

@ -34,22 +34,13 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
if (pixbuf->art_pixbuf->has_alpha || overall_alpha != 255)
gdk_pixbuf_composite_color (pixbuf, dest,
0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y,
(double) widget->allocation.width / pixbuf->art_pixbuf->width,
(double) widget->allocation.height / pixbuf->art_pixbuf->height,
filter_level, overall_alpha,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
else
gdk_pixbuf_scale (pixbuf, dest,
0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y,
(double) widget->allocation.width / pixbuf->art_pixbuf->width,
(double) widget->allocation.height / pixbuf->art_pixbuf->height,
filter_level);
gdk_pixbuf_composite_color (pixbuf, dest,
0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y,
(double) widget->allocation.width / pixbuf->art_pixbuf->width,
(double) widget->allocation.height / pixbuf->art_pixbuf->height,
filter_level, overall_alpha,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
0, 0, event->area.x, event->area.y,

View File

@ -27,6 +27,7 @@ tmpl_sources = \
tmpl/gnome-canvas-pixbuf.sgml \
tmpl/refcounting.sgml \
tmpl/rendering.sgml \
tmpl/scaling.sgml \
tmpl/util.sgml
gdk_pixbuf_docdir = $(HTML_DIR)
@ -56,7 +57,7 @@ scan:
-(cd $(srcdir) \
&& env CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \
gtkdoc-scanobj --module=$(DOC_MODULE) \
&& gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) )
&& gtkdoc-scan --module=$(DOC_MODULE) --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="pixops.h pixops-internal.h" )
templates: scan
cd $(srcdir) && gtkdoc-mktmpl --module=$(DOC_MODULE)

View File

@ -6,9 +6,23 @@ GdkPixbuf *pixbuf, gpointer user_data
<USER_FUNCTION>
<NAME>ModuleUpdatedNotifyFunc</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *pixbuf, gpointer user_data,
GdkPixbuf *pixbuf,
guint x, guint y,
guint width, guint height
guint width, guint height,
gpointer user_data
</USER_FUNCTION>
<USER_FUNCTION>
<NAME>ModuleFrameDoneNotifyFunc</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *pixbuf,
gint frame,
gpointer user_data
</USER_FUNCTION>
<USER_FUNCTION>
<NAME>ModuleAnimationDoneNotifyFunc</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *pixbuf,
gpointer user_data
</USER_FUNCTION>
<STRUCT>
<NAME>GdkPixbufModule</NAME>
@ -26,6 +40,8 @@ struct GdkPixbufModule {
gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
ModuleUpdatedNotifyFunc update_func,
ModuleFrameDoneNotifyFunc frame_done_func,
ModuleAnimationDoneNotifyFunc anim_done_func,
gpointer user_data);
void (* stop_load) (gpointer context);
gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
@ -275,6 +291,31 @@ GdkPixbuf *pixbuf, GdkDrawable *drawable,int src_x, int src_y,int dest_x, int de
GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int dest_x, int dest_y,int width, int height
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_scale</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_composite</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_composite_color</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha,int check_x,int check_y,int check_size,art_u32 color1,art_u32 color2
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_scale_simple</NAME>
<RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_composite_color_simple</NAME>
<RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level,int overall_alpha,int check_size,art_u32 color1,art_u32 color2
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_animation_new_from_file</NAME>
<RETURNS>GdkPixbufAnimation *</RETURNS>
const char *filename

View File

@ -60,6 +60,15 @@ gdk_pixbuf_animation_ref
gdk_pixbuf_animation_unref
</SECTION>
<SECTION>
<FILE>scaling</FILE>
gdk_pixbuf_scale
gdk_pixbuf_composite
gdk_pixbuf_composite_color
gdk_pixbuf_scale_simple
gdk_pixbuf_composite_color_simple
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-loader</FILE>
GDK_PIXBUF_LOADER

View File

@ -17,7 +17,7 @@
</ARG>
<ARG>
<NAME>GnomeCanvasPixbuf::width_in_pixels</NAME>
<NAME>GnomeCanvasPixbuf::width_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
@ -35,7 +35,7 @@
</ARG>
<ARG>
<NAME>GnomeCanvasPixbuf::height_in_pixels</NAME>
<NAME>GnomeCanvasPixbuf::height_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
@ -53,7 +53,7 @@
</ARG>
<ARG>
<NAME>GnomeCanvasPixbuf::x_in_pixels</NAME>
<NAME>GnomeCanvasPixbuf::x_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>
@ -71,7 +71,7 @@
</ARG>
<ARG>
<NAME>GnomeCanvasPixbuf::y_in_pixels</NAME>
<NAME>GnomeCanvasPixbuf::y_pixels</NAME>
<TYPE>gboolean</TYPE>
<FLAGS>rw</FLAGS>
</ARG>

View File

@ -4,6 +4,7 @@
<!entity gdk-pixbuf-file-loading SYSTEM "sgml/file-loading.sgml">
<!entity gdk-pixbuf-creating SYSTEM "sgml/creating.sgml">
<!entity gdk-pixbuf-rendering SYSTEM "sgml/rendering.sgml">
<!entity gdk-pixbuf-scaling SYSTEM "sgml/scaling.sgml">
<!entity gdk-pixbuf-from-drawables SYSTEM "sgml/from-drawables.sgml">
<!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml">
<!entity gdk-pixbuf-animation SYSTEM "sgml/animation.sgml">
@ -49,6 +50,7 @@
&gdk-pixbuf-file-loading;
&gdk-pixbuf-creating;
&gdk-pixbuf-rendering;
&gdk-pixbuf-scaling;
&gdk-pixbuf-from-drawables;
&gdk-pixbuf-util;
&gdk-pixbuf-animation;

View File

@ -13,13 +13,11 @@ Animations as multi-frame structures.
about the frame's overlay mode and duration.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbufLoader
</para>
<!-- ##### ENUM GdkPixbufFrameAction ##### -->
<para>
Each animation frame can have several things happen to it when the
@ -82,12 +80,11 @@ Animations as multi-frame structures.
</para>
@animation:
<!--
@animation: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -32,9 +32,7 @@ Getting parts of a drawable's image data into a pixbuf.
@dest_y:
@width:
@height:
@Returns:
<!--
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")

View File

@ -1,3 +1,14 @@
<!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
<para>
If this argument is %TRUE, then the width of the pixbuf will be
considered to be in pixels, that is, it will not be visually
scaled even if the item's affine transformation changes. If this
is %FALSE, then the width of the pixbuf will be considered to be
in canvas units, and so will be scaled normally by affine
transformations. The default is %FALSE.
</para>
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:See_Also ##### -->
<para>
@ -15,6 +26,14 @@
<!-- ##### ARG GnomeCanvasPixbuf:height_in_pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
argument. The default is %FALSE.
</para>
<!-- ##### STRUCT GdkPixbufModule ##### -->
<para>
@ -29,6 +48,21 @@
@stop_load:
@load_increment:
<!-- ##### ARG GnomeCanvasPixbuf:y_in_pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
argument. The default is %FALSE.
</para>
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:Long_Description ##### -->
<para>
@ -68,3 +102,14 @@ gdk-pixbuf-io
@size:
@Returns:
<!-- ##### ARG GnomeCanvasPixbuf:x_in_pixels ##### -->
<para>
If this argument is %TRUE, the pixbuf's translation with respect
to its logical origin in item-relative coordinates will be in
pixels, that is, the visible offset will not change even if the
item's affine transformation changes. If it is %FALSE, the
pixbuf's translation will be taken to be in canvas units, and thus
will change along with the item's affine transformation.
</para>

View File

@ -234,15 +234,10 @@ Canvas item to display #GdkPixbuf images.
used instead. This argument is %FALSE by default.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
<para>
If this argument is %TRUE, then the width of the pixbuf will be
considered to be in pixels, that is, it will not be visually
scaled even if the item's affine transformation changes. If this
is %FALSE, then the width of the pixbuf will be considered to be
in canvas units, and so will be scaled normally by affine
transformations. The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width_pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
<para>
@ -263,12 +258,10 @@ Canvas item to display #GdkPixbuf images.
The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height_in_pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
argument. The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
<para>
@ -287,15 +280,10 @@ Canvas item to display #GdkPixbuf images.
coordinates.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x_in_pixels ##### -->
<para>
If this argument is %TRUE, the pixbuf's translation with respect
to its logical origin in item-relative coordinates will be in
pixels, that is, the visible offset will not change even if the
item's affine transformation changes. If it is %FALSE, the
pixbuf's translation will be taken to be in canvas units, and thus
will change along with the item's affine transformation.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x_pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y ##### -->
<para>
@ -314,17 +302,8 @@ Canvas item to display #GdkPixbuf images.
default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y_in_pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
argument. The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y_pixels ##### -->
<para>
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
</para>

View File

@ -0,0 +1,162 @@
<!-- ##### SECTION Title ##### -->
Scaling
<!-- ##### SECTION Short_Description ##### -->
Scaling pixbufs and scaling and compositing pixbufs
<!-- ##### SECTION Long_Description ##### -->
<para>
gdk-pixbuf contains functions to scale pixbufs, to scale pixbufs and
composite against an existing image, and to scale pixbufs and
composite against a solid color or checkerboard. (Compositing a
checkerboard is a common way to show an image with an alpha-channel in
image-viewing and editing software.)
</para>
<para>
Since the full-featured functions (gdk_pixbuf_scale(),
gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
rather complex to use and have many arguments, two simple
convenience functions are provided, gdk_pixbuf_scale_simple()
and gdk_pixbuf_composite_color_simple() which create a
new pixbuf of a given size, scale an original image to fit,
and then return the new pixmap.
</para>
<para>
The following example demonstrates handling an expose event by
rendering the appropriate area of a source image (which is scaled to
fit the widget) onto the widget's window. The source image is
rendered against a checkerboard, which provides a visual
representation of the alpha channel if the image has one. If the image
doesn't have an alpha channel, calling gdk_pixbuf_composite_color()
function has exactly the same effect as calling gdk_pixbuf_scale().
</para>
<programlisting>
gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *dest;
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
gdk_pixbuf_composite_color (pixbuf, dest,
0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y,
(double) widget->allocation.width / pixbuf->art_pixbuf->width,
(double) widget->allocation.height / pixbuf->art_pixbuf->height,
filter_level, 255,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
0, 0, event->area.x, event->area.y,
event->area.width, event->area.height,
GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
gdk_pixbuf_unref (dest);
return TRUE;
}
</programlisting>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@filter_level:
<!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@filter_level:
@overall_alpha:
<!-- ##### FUNCTION gdk_pixbuf_composite_color ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@filter_level:
@overall_alpha:
@check_x:
@check_y:
@check_size:
@color1:
@color2:
<!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
<para>
</para>
@src:
@dest_width:
@dest_height:
@filter_level:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
<para>
</para>
@src:
@dest_width:
@dest_height:
@filter_level:
@overall_alpha:
@check_size:
@color1:
@color2:
@Returns:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -27,8 +27,7 @@ Utility and miscellaneous convenience functions.
@r:
@g:
@b:
@Returns:
<!--
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")

View File

@ -1,3 +1,16 @@
2000-01-05 Owen Taylor <otaylor@redhat.com>
* doc/Makefile.am doc/gdk-pixbuf-sections.txt
doc/gdk-pixbuf.sgml doc/tmpl/scaling.sgml:
Added scaling functions into gtk-doc framework.
* gdk-pixbuf/gdk-pixbuf-scale.c: Documentation fixes.
* gdk-pixbuf/testpixbuf-scale.c (expose_cb): Simplify a bit.
* gdk-pixbuf/pixops/pixops.c (pixops_composite_color): Return
immediately if scale_x or scale_y is 0.
2000-01-05 Owen Taylor <otaylor@redhat.com>
* gdk-pixbuf/pixops/timescale.c: quick fix for initializing

View File

@ -6,10 +6,10 @@
* gdk_pixbuf_scale:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x:
* @dest_y:
* @dest_width:
* @dest_height:
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
@ -49,10 +49,10 @@ gdk_pixbuf_scale (GdkPixbuf *src,
* gdk_pixbuf_composite:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x:
* @dest_y:
* @dest_width:
* @dest_height:
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
@ -93,10 +93,10 @@ gdk_pixbuf_composite (GdkPixbuf *src,
* gdk_pixbuf_composite_color:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x:
* @dest_y:
* @dest_width:
* @dest_height:
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction

View File

@ -1322,6 +1322,9 @@ pixops_composite_color (art_u8 *dest_buf,
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
if (scale_x == 0 || scale_y == 0)
return;
if (!src_has_alpha && overall_alpha == 255)
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
dest_rowstride, dest_channels, dest_has_alpha,
@ -1398,6 +1401,9 @@ pixops_composite (art_u8 *dest_buf,
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
if (scale_x == 0 || scale_y == 0)
return;
if (!src_has_alpha && overall_alpha == 255)
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
dest_rowstride, dest_channels, dest_has_alpha,
@ -1478,6 +1484,9 @@ pixops_scale (art_u8 *dest_buf,
g_return_if_fail (!(src_channels == 3 && src_has_alpha));
g_return_if_fail (!(src_has_alpha && !dest_has_alpha));
if (scale_x == 0 || scale_y == 0)
return;
switch (filter_level)
{
case ART_FILTER_NEAREST: