diff options
author | scuri <scuri> | 2010-01-07 19:12:08 +0000 |
---|---|---|
committer | scuri <scuri> | 2010-01-07 19:12:08 +0000 |
commit | a091243647ef5905e214b98fb42c5c3e334d2b64 (patch) | |
tree | 9df5ce8f92806ebb542a883aeccdb5683e3a4e1b /src/process | |
parent | f7cb3c864a65132c672da90a81627e49c98a1ca9 (diff) |
Included alpha support in all geometric and size operations.
Diffstat (limited to 'src/process')
-rw-r--r-- | src/process/im_geometric.cpp | 37 | ||||
-rw-r--r-- | src/process/im_resize.cpp | 24 |
2 files changed, 38 insertions, 23 deletions
diff --git a/src/process/im_geometric.cpp b/src/process/im_geometric.cpp index a0b5129..d4dbed3 100644 --- a/src/process/im_geometric.cpp +++ b/src/process/im_geometric.cpp @@ -2,7 +2,7 @@ * \brief Geometric Operations * * See Copyright Notice in im_lib.h - * $Id: im_geometric.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $ + * $Id: im_geometric.cpp,v 1.2 2010/01/07 19:12:53 scuri Exp $ */ @@ -393,7 +393,8 @@ static void InterlaceSplit(int src_width, void imProcessRotate90(const imImage* src_image, imImage* dst_image, int dir) { - for (int i = 0; i < src_image->depth; i++) + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -418,7 +419,8 @@ void imProcessRotate90(const imImage* src_image, imImage* dst_image, int dir) void imProcessRotate180(const imImage* src_image, imImage* dst_image) { - for (int i = 0; i < src_image->depth; i++) + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -446,9 +448,10 @@ int imProcessRadial(const imImage* src_image, imImage* dst_image, float k1, int int ret = 0; int counter = imCounterBegin("Radial Distort"); - imCounterTotal(counter, dst_image->depth*dst_image->height, "Processing..."); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, "Processing..."); /* size of the destiny image */ - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -483,9 +486,10 @@ int imProcessSwirl(const imImage* src_image, imImage* dst_image, float k, int or int ret = 0; int counter = imCounterBegin("Swirl Distort"); - imCounterTotal(counter, dst_image->depth*dst_image->height, "Processing..."); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, "Processing..."); /* size of the destiny image */ - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -559,7 +563,8 @@ int imProcessRotate(const imImage* src_image, imImage* dst_image, double cos0, d int ret = 0; int counter = imCounterBegin("Rotate"); - imCounterTotal(counter, dst_image->depth*dst_image->height, "Processing..."); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, "Processing..."); /* size of the destiny image */ if (src_image->color_space == IM_MAP) { @@ -567,7 +572,7 @@ int imProcessRotate(const imImage* src_image, imImage* dst_image, double cos0, d } else { - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -603,7 +608,8 @@ int imProcessRotateRef(const imImage* src_image, imImage* dst_image, double cos0 int ret = 0; int counter = imCounterBegin("RotateRef"); - imCounterTotal(counter, dst_image->depth*dst_image->height, "Processing..."); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, "Processing..."); /* size of the destiny image */ if (src_image->color_space == IM_MAP) { @@ -611,7 +617,7 @@ int imProcessRotateRef(const imImage* src_image, imImage* dst_image, double cos0 } else { - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -645,8 +651,9 @@ int imProcessRotateRef(const imImage* src_image, imImage* dst_image, double cos0 void imProcessMirror(const imImage* src_image, imImage* dst_image) { int i; + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; - for (i = 0; i < src_image->depth; i++) + for (i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -672,8 +679,9 @@ void imProcessMirror(const imImage* src_image, imImage* dst_image) void imProcessFlip(const imImage* src_image, imImage* dst_image) { int i; + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; - for (i = 0; i < src_image->depth; i++) + for (i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -699,8 +707,9 @@ void imProcessFlip(const imImage* src_image, imImage* dst_image) void imProcessInterlaceSplit(const imImage* src_image, imImage* dst_image1, imImage* dst_image2) { int i; + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; - for (i = 0; i < src_image->depth; i++) + for (i = 0; i < src_depth; i++) { switch(src_image->data_type) { diff --git a/src/process/im_resize.cpp b/src/process/im_resize.cpp index ddf6e47..4dbaa60 100644 --- a/src/process/im_resize.cpp +++ b/src/process/im_resize.cpp @@ -2,7 +2,7 @@ * \brief Image Resize * * See Copyright Notice in im_lib.h - * $Id: im_resize.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $ + * $Id: im_resize.cpp,v 1.2 2010/01/07 19:12:53 scuri Exp $ */ @@ -106,9 +106,10 @@ int imProcessReduce(const imImage* src_image, imImage* dst_image, int order) int ret = 0; int counter = imCounterBegin("Reduce Size"); const char* int_msg = (order == 1)? "Bilinear Decimation": "Zero Order Decimation"; - imCounterTotal(counter, src_image->depth*dst_image->height, int_msg); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, int_msg); - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -149,9 +150,10 @@ int imProcessResize(const imImage* src_image, imImage* dst_image, int order) int ret = 0; int counter = imCounterBegin("Resize"); const char* int_msg = (order == 3)? "Bicubic Interpolation": (order == 1)? "Bilinear Interpolation": "Zero Order Interpolation"; - imCounterTotal(counter, src_image->depth*dst_image->height, int_msg); + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + imCounterTotal(counter, src_depth*dst_image->height, int_msg); - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -219,8 +221,9 @@ static void ReduceBy4(int src_width, void imProcessReduceBy4(const imImage* src_image, imImage* dst_image) { int i; + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; - for (i = 0; i < src_image->depth; i++) + for (i = 0; i < src_depth; i++) { switch(src_image->data_type) { @@ -246,7 +249,8 @@ void imProcessReduceBy4(const imImage* src_image, imImage* dst_image) void imProcessCrop(const imImage* src_image, imImage* dst_image, int xmin, int ymin) { int type_size = imDataTypeSize(src_image->data_type); - for (int i = 0; i < src_image->depth; i++) + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + for (int i = 0; i < src_depth; i++) { imbyte *src_map = (imbyte*)src_image->data[i]; imbyte *dst_map = (imbyte*)dst_image->data[i]; @@ -269,6 +273,7 @@ void imProcessInsert(const imImage* src_image, const imImage* rgn_image, imImage int dst_offset2 = dst_size1+rgn_image->line_size; int ymax = ymin+rgn_image->height-1; int rgn_size = rgn_image->line_size; + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; if (dst_size2 < 0) { @@ -280,7 +285,7 @@ void imProcessInsert(const imImage* src_image, const imImage* rgn_image, imImage if (ymax > src_image->height-1) ymax = src_image->height-1; - for (int i = 0; i < src_image->depth; i++) + for (int i = 0; i < src_depth; i++) { imbyte *src_map = (imbyte*)src_image->data[i]; imbyte *rgn_map = (imbyte*)rgn_image->data[i]; @@ -315,7 +320,8 @@ void imProcessInsert(const imImage* src_image, const imImage* rgn_image, imImage void imProcessAddMargins(const imImage* src_image, imImage* dst_image, int xmin, int ymin) { int type_size = imDataTypeSize(src_image->data_type); - for (int i = 0; i < src_image->depth; i++) + int src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth; + for (int i = 0; i < src_depth; i++) { imbyte *dst_map = (imbyte*)dst_image->data[i]; imbyte *src_map = (imbyte*)src_image->data[i]; |