Linux GTK 缩放 (Scaling) — 缩放pixbuf和缩放并合并pixbuf
来源:互联网 发布:批量下载歌词软件 编辑:程序博客网 时间:2024/04/28 13:43
Linux GTK 缩放 (Scaling) — 缩放pixbuf和缩放并合并pixbuf
http://gtk-doc-cn.googlecode.com/svn/docs/gdk-pixbuf/gdk-pixbuf-%E7%BC%A9%E6%94%BE-%28Scaling%29.html
缩放 (Scaling)
缩放 (Scaling) — 缩放pixbuf和缩放并合并pixbuf。
Synopsis
#include <gdk-pixbuf/gdk-pixbuf.h>enum GdkInterpType;GdkPixbuf * gdk_pixbuf_scale_simple (const GdkPixbuf *src
,int dest_width
,int dest_height
,GdkInterpType interp_type
);void gdk_pixbuf_scale (const 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
,GdkInterpType interp_type
);GdkPixbuf * gdk_pixbuf_composite_color_simple (const GdkPixbuf *src
,int dest_width
,int dest_height
,GdkInterpType interp_type
,int overall_alpha
,int check_size
,guint32 color1
,guint32 color2
);void gdk_pixbuf_composite (const 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
,GdkInterpType interp_type
,int overall_alpha
);void gdk_pixbuf_composite_color (const 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
,GdkInterpType interp_type
,int overall_alpha
,int check_x
,int check_y
,int check_size
,guint32 color1
,guint32 color2
);enum GdkPixbufRotation;GdkPixbuf * gdk_pixbuf_rotate_simple (const GdkPixbuf *src
,GdkPixbufRotation angle
);GdkPixbuf * gdk_pixbuf_flip (const GdkPixbuf *src
,gboolean horizontal
);
Description
&gdk-pixbuf; 包含一些缩放pixbuf的函数,这些函数可以用来缩放pixbuf并与已有的图像合并,还可以缩放pixbuf并与实体颜色(solid color)或颜色棋盘(checkerboard)。与颜色棋盘(checkerboard)合并是图像查看和编辑软件显示带alpha通道的图像的常用方法。
因为完全特性(full-featured)函数(gdk_pixbuf_scale()
,gdk_pixbuf_composite()
, and gdk_pixbuf_composite_color()
)使用起来非常复杂而且有很多参数,所以提供了两个简单便捷的函数,gdk_pixbuf_scale_simple()
和 gdk_pixbuf_composite_color_simple()
,这两个函数按给定的大小创建一个新的pixbuf并将缩放原始图像来适应它,然后返回这个新的pixbuf。
Scaling and compositing functions take advantage of MMX hardwareacceleration on systems where MMX is supported. If gdk-pixbuf is builtwith the Sun mediaLib library, these functions are instead acceleratedusing mediaLib, which provides hardware acceleration on Intel, AMD,and Sparc chipsets. If desired, mediaLib support can be turned off bysetting the GDK_DISABLE_MEDIALIB environment variable.
下面的例子演示了通过将源图像(已经缩放到适合构件的尺寸)的一个适当的区域渲染到构件的窗体上来处理一个expose事件。这个源图像与一个棋盘(checkerboard)合成,如果源图像有alpha通道那么这个棋盘将提供一个alpha通道的视觉表现。如果源图像没有alpha通道,调用gdk_pixbuf_composite_color()
和 调用 gdk_pixbuf_scale()
的效果是完全一样的。
Example 2. 处理一个expose事件。
gbooleanexpose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data){ GdkPixbuf *dest; dest = gdk_pixbuf_new (GDK_COLORSPACE_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 / gdk_pixbuf_get_width (pixbuf), (double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf), GDK_INTERP_BILINEAR, 255, event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555); gdk_draw_pixbuf (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], dest, 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;}
Details
enum GdkInterpType
typedef enum {GDK_INTERP_NEAREST,GDK_INTERP_TILES,GDK_INTERP_BILINEAR,GDK_INTERP_HYPER} GdkInterpType;
This enumeration describes the different interpolation modes that can be used with the scaling functions.GDK_INTERP_NEAREST
is the fastest scaling method, but has horrible quality when scaling down.GDK_INTERP_BILINEAR
is the best choice if you aren't sure what to choose, it has a good speed/quality balance.
Note
Cubic filtering is missing from the list; hyperbolicinterpolation is just as fast and results in higher quality.GDK_INTERP_NEAREST
GDK_INTERP_TILES
GDK_INTERP_BILINEAR
GDK_INTERP_HYPER
gdk_pixbuf_scale_simple ()
GdkPixbuf * gdk_pixbuf_scale_simple (const GdkPixbuf *src
,int dest_width
,int dest_height
,GdkInterpType interp_type
);
创建一个包含 src
缩放到 dest_width
和dest_height
的新的 GdkPixbuf。保持 src
不受影响。如果想速度最大化可以给interp_type
传递 GDK_INTERP_NEAREST(但当 GDK_INTERP_NEAREST 缩小时图像一般会变的相当难看)。 interp_type
默认值为 GDK_INTERP_BILINEAR,该值提供了一个合理的质量和速度。
通过创建一个指向 $src 的 sub-pixbuf 可以缩放 src
的一部分;参见gdk_pixbuf_new_subpixbuf()
。
更复杂的缩放/合成请参见 gdk_pixbuf_scale()
和 gdk_pixbuf_composite()
。
src
:
dest_width
:
dest_height
:
interp_type
:
Returns :
一个新的 GdkPixbuf,内存不足返回NULL
。. [transfer full]gdk_pixbuf_scale ()
void gdk_pixbuf_scale (const 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
,GdkInterpType interp_type
);
通过 scale_x
和 $scale_y 指定的缩放以及 offset_x
和 offset_y
指定的偏移量创建一个原始图像src
的变形图像,并将其一个矩形区域(dest_x
,dest_y
, dest_width
,dest_height
)渲染到目标图像以取代先前的内容。
先尝试使用 gdk_pixbuf_scale_simple()
,如果 gdk_pixbuf_scale_simple()
不够强大时你可以退回来使用这是一个工业强度(industrial-strength)的有用工具。
如果源矩形重叠在同一个pixbuf目标矩形,在缩放渲染artifacts结果的期间它会被覆盖。
src
:
dest
:
dest_x
:
dest_y
:
dest_width
:
dest_height
:
offset_x
:
offset_x
:
scale_x
:
scale_y
:
interp_type
:
gdk_pixbuf_composite_color_simple ()
GdkPixbuf * gdk_pixbuf_composite_color_simple (const GdkPixbuf *src
,int dest_width
,int dest_height
,GdkInterpType interp_type
,int overall_alpha
,int check_size
,guint32 color1
,guint32 color2
);
通过缩放 src
到 dest_width
xdest_height
并将结果与颜色为 color1
和 color2
的棋盘合成来创建一个新的GdkPixbuf。
src
:
dest_width
:
dest_height
:
interp_type
:
overall_alpha
:
check_size
:
color1
: 左上方的格子的颜色color2
: 其他格子的颜色。Returns :
一个新的 GdkPixbuf,内存不足返回NULL
。. [transfer full]gdk_pixbuf_composite ()
void gdk_pixbuf_composite (const 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
,GdkInterpType interp_type
,int overall_alpha
);
通过 scale_x
和 $scale_y 指定的缩放以及 offset_x
和 offset_y
指定的偏移量创建一个原始图像src
的变形图像。这给出了一个在目标 pixbuf 坐标里的一个图像。该图像昂的一个矩形区域(dest_x
,dest_y
, dest_width
,dest_height
)会和原始目标图像的相应矩形区域合成。
当目标矩形包含一个并不在源图像之内的一个区域时,则源图像的边缘将被无限大的复制。
Figure 1. pixbuf 的合成
src
:
dest
:
dest_x
:
dest_y
:
dest_width
:
dest_height
:
offset_x
:
offset_x
:
scale_x
:
scale_y
:
interp_type
:
overall_alpha
:
gdk_pixbuf_composite_color ()
void gdk_pixbuf_composite_color (const 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
,GdkInterpType interp_type
,int overall_alpha
,int check_x
,int check_y
,int check_size
,guint32 color1
,guint32 color2
);
通过 scale_x
和 scale_y
指定的缩放以及offset_x
和 offset_y
指定的偏移量创建一个原始图像src
的变形图像,然后将这个变型图像的一个矩形区域(dest_x
,dest_y
,dest_width
, dest_height
)与color1
和 color2
组成的棋盘(checkboard)合成,并将其渲染到目标图像。
参见 gdk_pixbuf_composite_color_simple()
,一个适用于很多任务的比该函数更少参数的函数。
src
:
dest
:
dest_x
:
dest_y
:
dest_width
:
dest_height
:
offset_x
:
offset_x
:
scale_x
:
scale_y
:
interp_type
:
overall_alpha
:
check_x
:
check_x
, -check_y
)。check_y
:
check_size
:
color1
: 左上方的格子的颜色color2
: 其他格子的颜色。enum GdkPixbufRotation
typedef enum {GDK_PIXBUF_ROTATE_NONE = 0,GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90,GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180,GDK_PIXBUF_ROTATE_CLOCKWISE = 270} GdkPixbufRotation;
The possible rotations which can be passed to gdk_pixbuf_rotate_simple()
.To make them easier to use, their numerical values are the actual degrees.
GDK_PIXBUF_ROTATE_NONE
GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE
GDK_PIXBUF_ROTATE_UPSIDEDOWN
GDK_PIXBUF_ROTATE_CLOCKWISE
gdk_pixbuf_rotate_simple ()
GdkPixbuf * gdk_pixbuf_rotate_simple (const GdkPixbuf *src
,GdkPixbufRotation angle
);
旋转一个 pixbuf 90度的倍数,以一个新的 pixbuf 返回结果。
src
:
angle
:
Returns :
一个新的 GdkPixbuf,内存不足返回NULL
。. [transfer full]Since 2.6
gdk_pixbuf_flip ()
GdkPixbuf * gdk_pixbuf_flip (const GdkPixbuf *src
,gboolean horizontal
);
水平或竖直反转一个 pixbuf,以一个新的 pixbuf 返回结果。
src
:
horizontal
:
TRUE
为水平反转,FALSE
竖直反转。Returns :
一个新的 GdkPixbuf,内存不足返回NULL
。. [transfer full]Since 2.6
See Also
GdkRGB.- Linux GTK 缩放 (Scaling) — 缩放pixbuf和缩放并合并pixbuf
- pixbuf
- Feature Scaling 特征缩放
- 特征缩放(Feature Scaling)
- feature scaling 特征缩放
- 特征缩放(feature scaling)
- android 拖动和缩放 [Dragging and Scaling]
- 缩放
- 缩放
- GTK学习(3)-Lable、pixbuf、single、GtkEntry
- 在linux下使用gtk的gdk-pixbuf实现类似windows下的透明贴图
- gdk-pixbuf-csource: not found || cross compile gtk+ need gdk-pixbuf-csource
- 缩放图片并保存
- PHP普通缩放和等比缩放函数
- Linux 终端 字体缩放
- 位图旋转和缩放
- UIView翻转和缩放
- UIView翻转和缩放
- VC++ 如何检测某一个网卡是否连接上?net card connect detect
- linux下 tar解压 gz解压 bz2等各种解压文件使用方法
- Code Library 打印面
- 第一天
- 二叉树遍历非递归实现
- Linux GTK 缩放 (Scaling) — 缩放pixbuf和缩放并合并pixbuf
- 【Cocos2d-X开发学习笔记】第30期:游戏中数据的存储(下)
- C语言 数组、字符串长度及所占内存
- jsp读取大对象CLOB并生成xml文件示例
- UVA 437The Tower of Babylon (dp + DAG最长序列)
- Linux find命令
- 在activity的属性里加上这条属性,被该activity遮挡的Activity不会调用onStop()
- hdu(1719)Friend
- wim 显示 配置在/etc/vim文件夹下,新建vimrc.local