@@ -1020,7 +1020,7 @@ static inline void _gdScaleRow(gdImagePtr pSrc, unsigned int src_width, gdImage
1020
1020
}
1021
1021
}
1022
1022
1023
- static inline void _gdScaleHoriz (gdImagePtr pSrc , unsigned int src_width , unsigned int src_height , gdImagePtr pDst , unsigned int dst_width , unsigned int dst_height )
1023
+ static inline int _gdScaleHoriz (gdImagePtr pSrc , unsigned int src_width , unsigned int src_height , gdImagePtr pDst , unsigned int dst_width , unsigned int dst_height )
1024
1024
{
1025
1025
unsigned int u ;
1026
1026
LineContribType * contrib ;
@@ -1035,13 +1035,14 @@ static inline void _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsign
1035
1035
1036
1036
contrib = _gdContributionsCalc (dst_width , src_width , (double )dst_width / (double )src_width , pSrc -> interpolation );
1037
1037
if (contrib == NULL ) {
1038
- return ;
1038
+ return 0 ;
1039
1039
}
1040
1040
/* Scale each row */
1041
1041
for (u = 0 ; u < dst_height - 1 ; u ++ ) {
1042
1042
_gdScaleRow (pSrc , src_width , pDst , dst_width , u , contrib );
1043
1043
}
1044
1044
_gdContributionsFree (contrib );
1045
+ return 1 ;
1045
1046
}
1046
1047
1047
1048
static inline void _gdScaleCol (gdImagePtr pSrc , unsigned int src_width , gdImagePtr pRes , unsigned int dst_width , unsigned int dst_height , unsigned int uCol , LineContribType * contrib )
@@ -1066,7 +1067,7 @@ static inline void _gdScaleCol (gdImagePtr pSrc, unsigned int src_width, gdImag
1066
1067
}
1067
1068
}
1068
1069
1069
- static inline void _gdScaleVert (const gdImagePtr pSrc , const unsigned int src_width , const unsigned int src_height , const gdImagePtr pDst , const unsigned int dst_width , const unsigned int dst_height )
1070
+ static inline int _gdScaleVert (const gdImagePtr pSrc , const unsigned int src_width , const unsigned int src_height , const gdImagePtr pDst , const unsigned int dst_width , const unsigned int dst_height )
1070
1071
{
1071
1072
unsigned int u ;
1072
1073
LineContribType * contrib ;
@@ -1081,19 +1082,21 @@ static inline void _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_w
1081
1082
1082
1083
contrib = _gdContributionsCalc (dst_height , src_height , (double )(dst_height ) / (double )(src_height ), pSrc -> interpolation );
1083
1084
if (contrib == NULL ) {
1084
- return ;
1085
+ return 0 ;
1085
1086
}
1086
1087
/* scale each column */
1087
1088
for (u = 0 ; u < dst_width - 1 ; u ++ ) {
1088
1089
_gdScaleCol (pSrc , src_width , pDst , dst_width , dst_height , u , contrib );
1089
1090
}
1090
1091
_gdContributionsFree (contrib );
1092
+ return 1 ;
1091
1093
}
1092
1094
1093
1095
gdImagePtr gdImageScaleTwoPass (const gdImagePtr src , const unsigned int src_width , const unsigned int src_height , const unsigned int new_width , const unsigned int new_height )
1094
1096
{
1095
1097
gdImagePtr tmp_im ;
1096
1098
gdImagePtr dst ;
1099
+ int scale_pass_res ;
1097
1100
1098
1101
if (new_width == 0 || new_height == 0 ) {
1099
1102
return NULL ;
@@ -1109,38 +1112,26 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
1109
1112
return NULL ;
1110
1113
}
1111
1114
gdImageSetInterpolationMethod (tmp_im , src -> interpolation_id );
1112
- _gdScaleHoriz (src , src_width , src_height , tmp_im , new_width , src_height );
1115
+ scale_pass_res = _gdScaleHoriz (src , src_width , src_height , tmp_im , new_width , src_height );
1116
+ if (scale_pass_res != 1 ) {
1117
+ gdImageDestroy (tmp_im );
1118
+ return NULL ;
1119
+ }
1113
1120
1114
1121
dst = gdImageCreateTrueColor (new_width , new_height );
1115
1122
if (dst == NULL ) {
1116
1123
gdImageDestroy (tmp_im );
1117
1124
return NULL ;
1118
1125
}
1119
1126
gdImageSetInterpolationMethod (dst , src -> interpolation_id );
1120
- _gdScaleVert (tmp_im , new_width , src_height , dst , new_width , new_height );
1121
- gdImageDestroy (tmp_im );
1122
-
1123
- return dst ;
1124
- }
1125
-
1126
- gdImagePtr Scale (const gdImagePtr src , const unsigned int src_width , const unsigned int src_height , const gdImagePtr dst , const unsigned int new_width , const unsigned int new_height )
1127
- {
1128
- gdImagePtr tmp_im ;
1129
-
1130
- if (new_width == 0 || new_height == 0 ) {
1131
- return NULL ;
1132
- }
1133
-
1134
- tmp_im = gdImageCreateTrueColor (new_width , src_height );
1135
- if (tmp_im == NULL ) {
1127
+ scale_pass_res = _gdScaleVert (tmp_im , new_width , src_height , dst , new_width , new_height );
1128
+ if (scale_pass_res != 1 ) {
1129
+ gdImageDestroy (dst );
1130
+ gdImageDestroy (tmp_im );
1136
1131
return NULL ;
1137
1132
}
1138
- gdImageSetInterpolationMethod (tmp_im , src -> interpolation_id );
1139
-
1140
- _gdScaleHoriz (src , src_width , src_height , tmp_im , new_width , src_height );
1141
- _gdScaleVert (tmp_im , new_width , src_height , dst , new_width , new_height );
1142
-
1143
1133
gdImageDestroy (tmp_im );
1134
+
1144
1135
return dst ;
1145
1136
}
1146
1137
0 commit comments