/**
* libpsd - Photoshop file formats (*.psd) decode library
* Copyright (C) 2004-2007 Graphest Software.
*
* libpsd is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 Library General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: boundary.c, created by Patrick in 2006.07.19, libpsd@graphest.com Exp $
*
* Notice: we use some codes form the libart to implement the boundary and stroke,
* but we found there is a bug that causes the segment when it's rendering the boundary,
* and we don't know how to fix it.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "libpsd.h"
#include "psd_system.h"
#include "psd_bitmap.h"
#include "psd_color.h"
#include "psd_math.h"
#define PSD_BOUNDARY_THRESHOLD 24
/* BoundSeg array growth parameter */
#define PSD_BOUNDARY_MAX_SEGS_INC 2048
#define PSD_EPSILON 1e-6
#define PSD_EPSILON_2 1e-12
#define PSD_EPSILON_A 1e-5 /* Threshold for breaking lines at point insertions */
#define PSD_M_SQRT2 1.41421356237309504880 /* sqrt(2) */
/* Note: BNEG is 1 for \ lines, and 0 for /. Thus,
x[(flags & BNEG) ^ 1] <= x[flags & BNEG] */
#define PSD_ART_ACTIVE_FLAGS_BNEG 1
/* This flag is set if the segment has been inserted into the active
list. */
#define PSD_ART_ACTIVE_FLAGS_IN_ACTIVE 2
/* This flag is set when the segment is to be deleted in the
horiz commit process. */
#define PSD_ART_ACTIVE_FLAGS_DEL 4
/* This flag is set if the seg_id is a valid output segment. */
#define PSD_ART_ACTIVE_FLAGS_OUT 8
/* This flag is set if the segment is in the horiz list. */
#define PSD_ART_ACTIVE_FLAGS_IN_HORIZ 16
typedef struct _psd_gimp_bound_seg
{
psd_int x1;
psd_int y1;
psd_int x2;
psd_int y2;
psd_bool open;
psd_bool visited;
} psd_gimp_bound_seg;
typedef struct _psd_gimp_boundary
{
/* The array of segments */
psd_gimp_bound_seg * segs;
psd_int num_segs;
psd_int max_segs;
/* The array of vertical segments */
psd_int * vert_segs;
/* The empty segment arrays */
psd_int * empty_segs_n;
psd_int * empty_segs_c;
psd_int * empty_segs_l;
psd_int max_empty_segs;
} psd_gimp_boundary;
typedef struct _psd_vector2
{
psd_double x, y;
} psd_gimp_vector2;
typedef struct _psd_art_point {
/*< public >*/
psd_double x, y;
} psd_art_point;
typedef struct _psd_art_drect {
/*< public >*/
psd_double x0, y0, x1, y1;
} psd_art_drect;
typedef enum {
PSD_ART_MOVETO,
PSD_ART_MOVETO_OPEN,
PSD_ART_CURVETO,
PSD_ART_LINETO,
PSD_ART_END
} psd_art_pathcode;
typedef enum {
PSD_ART_WIND_RULE_NONZERO,
PSD_ART_WIND_RULE_INTERSECT,
PSD_ART_WIND_RULE_ODDEVEN,
PSD_ART_WIND_RULE_POSITIVE
} psd_art_wind_rule;
typedef enum {
PSD_ART_BREAK_LEFT = 1,
PSD_ART_BREAK_RIGHT = 2
} psd_art_break_flags;
/* CURVETO is not allowed! */
typedef struct _psd_art_vpath {
psd_art_pathcode code;
psd_double x;
psd_double y;
} psd_art_vpath;
typedef struct _psd_art_svp_seg {
psd_int n_points;
psd_int dir; /* == 0 for "up", 1 for "down" */
psd_art_drect bbox;
psd_art_point *points;
} psd_art_svp_seg;
typedef struct _psd_art_svp {
psd_int n_segs;
psd_art_svp_seg segs[1];
} psd_art_svp;
typedef struct _psd_gimp_scan_convert
{
psd_double ratio_xy;
psd_bool clip;
psd_int clip_x;
psd_int clip_y;
psd_int clip_w;
psd_int clip_h;
/* stuff necessary for the _add_polygons API... :-/ */
psd_bool got_first;
psd_bool need_closing;
psd_gimp_vector2 first;
psd_gimp_vector2 prev;
psd_bool have_open;
psd_int num_nodes;
psd_art_vpath *vpath;
psd_art_svp *svp; /* Sorted vector path
(extension no longer possible) */
/* stuff necessary for the rendering callback */
psd_bitmap * dst_bmp;
psd_int x0;
psd_int x1;
} psd_gimp_scan_convert;
typedef struct _psd_art_svp_writer psd_art_svp_writer;
struct _psd_art_svp_writer {
psd_int (*add_segment)(psd_art_svp_writer *self, psd_int wind_left, psd_int delta_wind,
psd_double x, psd_double y);
void (*add_point)(psd_art_svp_writer *self, psd_int seg_id, psd_double x, psd_double y);
void (*close_segment)(psd_art_svp_writer *self, psd_int seg_id);
};
typedef struct _psd_art_svp_writer_rewind {
psd_art_svp_writer super;
psd_art_wind_rule rule;
psd_art_svp *svp;
psd_int n_segs_max;
psd_int *n_points_max;
} psd_art_svp_writer_rewind;
typedef struct _psd_art_pri_point {
psd_double x;
psd_double y;
void *user_data;
} psd_art_pri_point;
typedef struct _psd_art_pri_q {
psd_int n_items;
psd_int n_items_max;
psd_art_pri_point **items;
} psd_art_pri_q;
typedef struct _psd_art_active_seg psd_art_active_seg;
struct _psd_art_active_seg {
psd_int flags;
psd_int wind_left, delta_wind;
psd_art_active_seg *left, *right; /* doubly linked list structure */
const psd_art_svp_seg *in_seg;
psd_int in_curs;
psd_double x[2];
psd_double y0, y1;
psd_double a, b, c; /* line equation; ax+by+c = 0 for the line, a^2 + b^2 = 1,
and a>0 */
/* bottom point and intersection point stack */
psd_int n_stack;
psd_int n_stack_max;
psd_art_point *stack;
/* horiz commit list */
psd_art_active_seg *horiz_left, *horiz_right;
psd_double horiz_x;
psd_int horiz_delta_wind;
psd_int seg_id;
};
typedef struct _psd_art_intersect_ctx {
const psd_art_svp *in;
psd_art_svp_writer *out;
psd_art_pri_q *pq;
psd_art_active_seg *active_head;
psd_double y;
psd_art_active_seg *horiz_first;
psd_art_active_seg *horiz_last;
/* segment index of next input segment to be added to pri q */
psd_int in_curs;
} psd_art_intersect_ctx;
typedef struct _psd_art_svp_render_aa_step {
psd_int x;
psd_int delta; /* stored with 16 fractional bits */
} psd_art_svp_render_aa_step;
typedef struct _psd_art_svp_render_aa_iter {
const psd_art_svp *svp;
psd_int x0, x1;
psd_int y;
psd_int seg_ix;
psd_int *active_segs;
psd_int n_active_segs;
psd_int *cursor;
psd_double *seg_x;
psd_double *seg_dx;
psd_art_svp_render_aa_step *steps;
} psd_art_svp_render_aa_iter;
extern psd_float psd_carm_sqrt(psd_float x);
static psd_bool psd_get_bounds(psd_bitmap * src_bmp, psd_int *x1, psd_int *y1, psd_int *x2, psd_int *y2)
{
psd_int tx1, tx2, ty1, ty2;
psd_int i, j, width, height;
psd_argb_color * image_data;
/* go through and calculate the bounds */
tx1 = src_bmp->width;
ty1 = src_bmp->height;
tx2 = 0;
ty2 = 0;
width = src_bmp->width;
height = src_bmp->height;
for(i = 0; i < height; i ++)
{
if(tx1 > 0)
{
image_data = src_bmp->image_data + i * width;
for(j = 0; j < tx1; j ++)
{
if(*image_data > 0x00FFFFFF)
{
tx1 = j;
break;
}
image_data ++;
}
}
if(tx2 < width)
{
image_data = src_bmp->image_data + i * width + width - 1;
for(j = width - 1; j >= tx2; j --)
{
if(*image_data > 0x00FFFFFF)
没有合适的资源?快使用搜索试试~ 我知道了~
Visual C++开发实战1200例-光盘第14章源码.part.rar
共1641个文件
h:592个
c:450个
cpp:131个
5星 · 超过95%的资源 需积分: 3 14 下载量 109 浏览量
2014-04-07
21:31:37
上传
评论
收藏 45.16MB RAR 举报
温馨提示
Visual C++开发实战1200例-光盘第14章源码.part.rar
资源推荐
资源详情
资源评论
收起资源包目录
Visual C++开发实战1200例-光盘第14章源码.part.rar (1641个子文件)
0362.bmp 788KB
test.bmp 781KB
result.bmp 703KB
BMA-012.bmp 606KB
bitmap.bmp 585KB
R2_MASKPENNOT.bmp 448KB
R2_MERGEPEN.bmp 448KB
R2_NOTMERGEPEN.bmp 448KB
R2_NOT.bmp 448KB
R2_BLACK.bmp 448KB
R2_NOTCOPYPEN.bmp 448KB
R2_NOTMASKPEN.bmp 448KB
R2_MASKNOTPEN.bmp 448KB
R2_MERGEPENNOT.bmp 448KB
R2_NOP.bmp 448KB
R2_XORPEN.bmp 448KB
R2_NOTXORPEN.bmp 448KB
R2_WHITE.bmp 448KB
R2_MASKPEN.bmp 448KB
R2_COPYPEN.bmp 448KB
R2_MERGENOTPEN.bmp 448KB
test.bmp 364KB
bitmap.bmp 364KB
bitmap.bmp 364KB
bitmap.bmp 364KB
bitmap.bmp 364KB
2.bmp 348KB
1.bmp 348KB
3.bmp 348KB
CH01-001.bmp 325KB
bitmap.bmp 246KB
test.bmp 80KB
公交车.bmp 37KB
mr.bmp 26KB
bitmap.bmp 11KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
Toolbar.bmp 1KB
MulWaterMark.bsc 3.59MB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
boundary.c 96KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
blend.c 44KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
descriptor.c 36KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
layer_mask.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
image_resource.c 31KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
pattern.c 27KB
channel_image.c 27KB
channel_image.c 27KB
channel_image.c 27KB
共 1641 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
- zhujunfengx2014-06-01可以用。不错。就是分的太多了,能搞成一个包就最好了。
- naikou2015-08-18很好,感谢分享!
yoayuqin
- 粉丝: 0
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功