148 |
} |
} |
149 |
} |
} |
150 |
|
|
151 |
#if 0 |
#if 1 |
152 |
|
|
153 |
static int gcd(int a, int b) |
static int gcd(int a, int b) |
154 |
{ |
{ |
168 |
static void image_resize(EditState *s) |
static void image_resize(EditState *s) |
169 |
{ |
{ |
170 |
ImageState *is = s->mode_data; |
ImageState *is = s->mode_data; |
171 |
|
ImageBuffer *ib = s->b->data; |
172 |
int d, w, h; |
int d, w, h; |
173 |
|
|
174 |
/* simplify factors */ |
/* simplify factors */ |
180 |
is->yfactor_num /= d; |
is->yfactor_num /= d; |
181 |
is->yfactor_den /= d; |
is->yfactor_den /= d; |
182 |
|
|
183 |
w = ((long long)is->img.width * (long long)is->xfactor_num) / |
w = ((long long)ib->width * (long long)is->xfactor_num) / |
184 |
is->xfactor_den; |
is->xfactor_den; |
185 |
h = ((long long)is->img.height * (long long)is->yfactor_num) / |
h = ((long long)ib->height * (long long)is->yfactor_num) / |
186 |
is->yfactor_den; |
is->yfactor_den; |
187 |
|
|
188 |
if (w < 1) |
if (w < 1) |
194 |
if (w == is->w && |
if (w == is->w && |
195 |
h == is->h) |
h == is->h) |
196 |
return; |
return; |
197 |
|
|
198 |
|
edit_invalidate(s); |
199 |
} |
} |
200 |
|
|
201 |
|
|
221 |
is->xfactor_den *= 100; |
is->xfactor_den *= 100; |
222 |
is->yfactor_num *= (100 + percent); |
is->yfactor_num *= (100 + percent); |
223 |
is->yfactor_den *= 100; |
is->yfactor_den *= 100; |
224 |
|
|
225 |
image_resize(s); |
image_resize(s); |
226 |
} |
} |
227 |
|
|
228 |
static void image_set_size(EditState *s, int w, int h) |
static void image_set_size(EditState *s, int w, int h) |
229 |
{ |
{ |
230 |
ImageState *is = s->mode_data; |
ImageState *is = s->mode_data; |
231 |
|
ImageBuffer *ib = s->b->data; |
232 |
|
|
233 |
if (w < 1 || h < 1) { |
if (w < 1 || h < 1) { |
234 |
put_status(s, "Invalid image size"); |
put_status(s, "Invalid image size"); |
236 |
} |
} |
237 |
|
|
238 |
is->xfactor_num = w; |
is->xfactor_num = w; |
239 |
is->xfactor_den = is->img.width; |
is->xfactor_den = ib->width; |
240 |
is->yfactor_num = h; |
is->yfactor_num = h; |
241 |
is->yfactor_den = is->img.height; |
is->yfactor_den = ib->height; |
242 |
|
|
243 |
image_resize(s); |
image_resize(s); |
244 |
} |
} |
560 |
{ |
{ |
561 |
int d; |
int d; |
562 |
|
|
563 |
h = SCROLL_MHEIGHT; |
d = SCROLL_MHEIGHT; |
564 |
if (abs(dir) == 2) { |
if (abs(dir) == 2) { |
565 |
/* move 50% */ |
/* move 50% */ |
566 |
d = s->height / 2; |
d = s->height / 2; |
810 |
CMD_( 'b', KEY_NONE, "image-set-background-color", |
CMD_( 'b', KEY_NONE, "image-set-background-color", |
811 |
image_set_background_color, |
image_set_background_color, |
812 |
"s{Background color (use 'transparent' for tiling): }") |
"s{Background color (use 'transparent' for tiling): }") |
813 |
#if 0 |
#if 1 |
814 |
CMD0( 'n', KEY_NONE, "image-normal-size", image_normal_size) |
CMD0( 'n', KEY_NONE, "image-normal-size", image_normal_size) |
815 |
CMD1( '>', KEY_NONE, "image-double-size", image_mult_size, 100) |
CMD1( '>', KEY_NONE, "image-double-size", image_mult_size, 100) |
816 |
CMD1( '<', KEY_NONE, "image-halve-size", image_mult_size, -50) |
CMD1( '<', KEY_NONE, "image-halve-size", image_mult_size, -50) |