/*
* Copyright (C) 2000 Red Hat, Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <math.h>
#include <glib.h>
#include "pixops.h"
#include "pixops-internal.h"
#define SUBSAMPLE_BITS 4
#define SUBSAMPLE (1 << SUBSAMPLE_BITS)
#define SUBSAMPLE_MASK ((1 << SUBSAMPLE_BITS)-1)
#define SCALE_SHIFT 16
typedef struct _PixopsFilter PixopsFilter;
typedef struct _PixopsFilterDimension PixopsFilterDimension;
struct _PixopsFilterDimension
{
int n;
double offset;
double *weights;
};
struct _PixopsFilter
{
PixopsFilterDimension x;
PixopsFilterDimension y;
double overall_alpha;
};
typedef guchar *(*PixopsLineFunc) (int *weights, int n_x, int n_y,
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
guchar **src, int src_channels, gboolean src_has_alpha,
int x_init, int x_step, int src_width,
int check_size, guint32 color1, guint32 color2);
typedef void (*PixopsPixelFunc) (guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
int src_has_alpha, int check_size, guint32 color1,
guint32 color2,
guint r, guint g, guint b, guint a);
static int
get_check_shift (int check_size)
{
int check_shift = 0;
g_return_val_if_fail (check_size >= 0, 4);
while (!(check_size & 1))
{
check_shift++;
check_size >>= 1;
}
return check_shift;
}
static void
pixops_scale_nearest (guchar *dest_buf,
int render_x0,
int render_y0,
int render_x1,
int render_y1,
int dest_rowstride,
int dest_channels,
G_GNUC_UNUSED gboolean dest_has_alpha,
const guchar *src_buf,
int src_width,
int src_height,
int src_rowstride,
int src_channels,
G_GNUC_UNUSED gboolean src_has_alpha,
double scale_x,
double scale_y)
{
int i;
int x;
int x_step = (1 << SCALE_SHIFT) / scale_x;
int y_step = (1 << SCALE_SHIFT) / scale_y;
int xmax, xstart, xstop, x_pos, y_pos;
const guchar *p;
#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS,ASSIGN_PIXEL) \
xmax = x + (render_x1 - render_x0) * x_step; \
xstart = MIN (0, xmax); \
xstop = MIN (src_width << SCALE_SHIFT, xmax); \
p = src + (CLAMP (x, xstart, xstop) >> SCALE_SHIFT) * SRC_CHANNELS; \
while (x < xstart) \
{ \
ASSIGN_PIXEL; \
dest += DEST_CHANNELS; \
x += x_step; \
} \
while (x < xstop) \
{ \
p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \
ASSIGN_PIXEL; \
dest += DEST_CHANNELS; \
x += x_step; \
} \
x_pos = x >> SCALE_SHIFT; \
p = src + CLAMP (x_pos, 0, src_width - 1) * SRC_CHANNELS; \
while (x < xmax) \
{ \
ASSIGN_PIXEL; \
dest += DEST_CHANNELS; \
x += x_step; \
}
for (i = 0; i < (render_y1 - render_y0); i++)
{
const guchar *src;
guchar *dest;
y_pos = ((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT;
y_pos = CLAMP (y_pos, 0, src_height - 1);
src = src_buf + y_pos * src_rowstride;
dest = dest_buf + i * dest_rowstride;
x = render_x0 * x_step + x_step / 2;
if (src_channels == 3)
{
if (dest_channels == 3)
{
INNER_LOOP (3, 3, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2]);
}
else
{
INNER_LOOP (3, 4, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2];dest[3]=0xff);
}
}
else if (src_channels == 4)
{
if (dest_channels == 3)
{
INNER_LOOP (4, 3, dest[0]=p[0];dest[1]=p[1];dest[2]=p[2]);
}
else
{
guint32 *p32;
INNER_LOOP(4, 4, p32=(guint32*)dest;*p32=*((guint32*)p));
}
}
else if (src_channels == 2)
{
if (dest_channels == 2)
{
INNER_LOOP (2, 2, dest[0]=p[0];dest[1]=p[1]);
}
}
}
}
static void
pixops_composite_nearest (guchar *dest_buf,
int render_x0,
int render_y0,
int render_x1,
int render_y1,
int dest_rowstride,
int dest_channels,
gboolean dest_has_alpha,
const guchar *src_buf,
int src_width,
int src_height,
int src_rowstride,
int src_channels,
gboolean src_has_alpha,
double scale_x,
double scale_y,
int overall_alpha)
{
int i;
int x;
int x_step = (1 << SCALE_SHIFT) / scale_x;
int y_step = (1 << SCALE_SHIFT) / scale_y;
int xmax, xstart, xstop, x_pos, y_pos;
const guchar *p;
unsigned int a0;
for (i = 0; i < (render_y1 - render_y0); i++)
{
const guchar *src;
guchar *dest;
y_pos = ((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT;
y_pos = CLAMP (y_pos, 0, src_height - 1);
src = src_buf + y_pos * src_rowstride;
dest = dest_buf + i * dest_rowstride;
x = render_x0 * x_step + x_step / 2;
INNER_LOOP(src_channels, dest_channels,
if (src_has_alpha)
a0 = (p[3] * overall_alpha) / 0xff;
else
a0 = overall_alpha;
switch (a0)
{
case 0:
break;
case 255:
dest[0] = p[0];
dest[1] = p[1];
dest[2] = p[2];
if (dest_has_alpha)
dest[3] = 0xff;
break;
default:
if (dest_has_alpha)
{
unsigned int w0 = 0xff * a0;
unsigned int w1 = (0xff - a0) * dest[3];
unsigned int w = w0 + w1;
dest[0] = (w0 * p[0] + w1 * dest[0]) / w;
dest[1] = (w0 * p[1] + w1 * dest[1]) / w;
dest[2] = (w0 * p[2] + w1 * dest[2]) / w;
dest[3] = w / 0xff;
}
else
{
unsigned int a1 = 0xff - a0;
unsigned int tmp;
tmp = a0 * p[0] + a1 * dest[0] + 0x80;
dest[0] = (tmp + (tmp >> 8)) >> 8;
tmp = a0 * p[1] + a1 * dest[1] + 0x80;
dest[1] = (tmp + (tmp >> 8)) >> 8;
tmp = a0 * p[2] + a1 * dest[2] + 0x80;
dest[2] = (tmp + (tmp >> 8)) >> 8;
}
break;
}
);
}
}
static void
pixops_composit
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ekiga-3.2.7.rar_Ekiga_ekiga-3.2.7_h323_sip视频会议_视频会议 (937个子文件)
ekiga.1 3KB
configure.ac 27KB
Makefile.am 7KB
Makefile.am 5KB
Makefile.am 5KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 1015B
Makefile.am 977B
Makefile.am 931B
Makefile.am 907B
Makefile.am 899B
Makefile.am 887B
Makefile.am 872B
Makefile.am 870B
Makefile.am 785B
Makefile.am 784B
Makefile.am 776B
Makefile.am 753B
Makefile.am 749B
Makefile.am 749B
Makefile.am 745B
Makefile.am 729B
Makefile.am 722B
Makefile.am 696B
Makefile.am 662B
Makefile.am 638B
Makefile.am 632B
Makefile.am 627B
Makefile.am 593B
Makefile.am 587B
Makefile.am 584B
Makefile.am 559B
Makefile.am 505B
Makefile.am 496B
Makefile.am 479B
Makefile.am 456B
Makefile.am 430B
Makefile.am 415B
Makefile.am 409B
Makefile.am 380B
Makefile.am 378B
Makefile.am 359B
Makefile.am 198B
Makefile.am 54B
Makefile.am 32B
AUTHORS 3KB
pixops.c 46KB
gmconf-glib.c 37KB
gmpreferences.c 34KB
gm-smiley-chooser-button.c 23KB
gmlevelmeter.c 18KB
gmcellrendererexpander.c 17KB
gmmenuaddon.c 16KB
gmdialog.c 13KB
gmconfwidgets.c 12KB
gmwindow.c 12KB
gmconf-gconf.c 10KB
gmmarshallers.c 10KB
gm-cell-renderer-bitext.c 10KB
gmpowermeter.c 7KB
timescale.c 7KB
gm-text-anchored-tag.c 6KB
gm-text-buffer-enhancer.c 6KB
gmconnectbutton.c 6KB
gm-text-extlink.c 6KB
gm-text-smiley.c 6KB
gmstatusbar.c 5KB
gmstockicons.c 5KB
gmentrydialog.c 4KB
gm-text-buffer-enhancer-helper-iface.c 3KB
hal-v4l-helper.c 3KB
toolbox-common.c 3KB
platform-win32.c 2KB
toolbox-internal.c 2KB
gm-smileys.c 2KB
toolbox-win32.c 2KB
toolbox-gtk.c 2KB
toolbox-gnome.c 2KB
platform-generic.c 2KB
ChangeLog 1MB
ChangeLog 152KB
ChangeLog 9KB
configure 686KB
COPYING 18KB
main.cpp 151KB
assistant.cpp 57KB
preferences.cpp 49KB
roster-view-gtk.cpp 47KB
form-dialog-gtk.cpp 37KB
dxwindow.cpp 35KB
共 937 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
JonSco
- 粉丝: 67
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功