Lines Matching refs:scale

67 #define Offset(field) XtOffsetOf(ScaleRec, scale.field)
220 values.foreground = sw->scale.foreground_pixel;
224 sw->scale.gc = XtGetGC((Widget) sw,
238 if (sw->scale.proportional) {
239 sw->scale.scale_x = sw->scale.scale_y =
240 ((sw->scale.aspect_ratio > 1.0) ?
241 sw->scale.aspect_ratio : 1.0 / sw->scale.aspect_ratio) *
242 (sw->scale.precision > 1.0 ?
243 sw->scale.precision : 1.0);
247 sw->scale.scale_x = sw->scale.scale_y = 1.0;
265 sw->scale.rectangles = (XRectangle *)
266 XtRealloc((char *) sw->scale.rectangles,
268 sw->scale.buffer_size = buffer_size;
280 new_sw->scale.table.x = (Position *) NULL;
281 new_sw->scale.table.y = (Position *) NULL;
282 new_sw->scale.table.width = (Dimension *) NULL;
283 new_sw->scale.table.height = (Dimension *) NULL;
285 new_sw->scale.nrectangles = 0;
286 new_sw->scale.rectangles = (XRectangle *) NULL;
288 GetRectangleBuffer(new_sw, new_sw->scale.buffer_size);
292 if (new_sw->scale.image != NULL) {
295 new_sw->scale.image->width + 2 * new_sw->scale.internal_width;
298 new_sw->scale.image->height + 2 *new_sw->scale.internal_height;
302 new_sw->core.width = 1 + 2 * new_sw->scale.internal_width;
304 new_sw->core.height = 1 + 2 * new_sw->scale.internal_height;
305 new_sw->scale.image = XCreateImage(XtDisplay(new),
313 if ((new_sw->scale.aspect_ratio =
314 atof(new_sw->scale.aspect_ratio_str)) < 0.0) {
315 new_sw->scale.aspect_ratio = 1.0;
319 if ((new_sw->scale.precision =
320 atof(new_sw->scale.precision_str)) < 0.0) {
321 new_sw->scale.precision = 0.001;
325 if (new_sw->scale.scale_x_str == DefaultScaleFactor
327 new_sw->scale.scale_y_str == DefaultScaleFactor)
330 if ((new_sw->scale.scale_x =
331 atof(new_sw->scale.scale_x_str)) < 0.0) {
332 new_sw->scale.scale_x = 1.0;
335 if ((new_sw->scale.scale_y =
336 atof(new_sw->scale.scale_y_str)) < 0.0) {
337 new_sw->scale.scale_y = 1.0;
349 * This procedure builds scaling table for image in the scale struct
355 XtFree((char *) sw->scale.table.x);
356 XtFree((char *) sw->scale.table.y);
357 XtFree((char *) sw->scale.table.width);
358 XtFree((char *) sw->scale.table.height);
359 sw->scale.table.x =
360 (Position *) XtMalloc(sizeof(Position) * sw->scale.image->width);
361 sw->scale.table.y =
362 (Position *) XtMalloc(sizeof(Position) * sw->scale.image->height);
363 sw->scale.table.width =
364 (Dimension *) XtMalloc(sizeof(Dimension) * sw->scale.image->width);
365 sw->scale.table.height =
366 (Dimension *) XtMalloc(sizeof(Dimension) * sw->scale.image->height);
369 for (x = 0; x < sw->scale.image->width; x++) {
370 sw->scale.table.x[(int) x] = (Position) myrint(sw->scale.scale_x * x);
371 sw->scale.table.width[(int) x] = (Dimension)
372 myrint(sw->scale.scale_x *(x + 1)) - myrint(sw->scale.scale_x * x);
374 for (y = 0; y < sw->scale.image->height; y++) {
375 sw->scale.table.y[(int) y] = (Position) myrint(sw->scale.scale_y * y);
376 sw->scale.table.height[(int) y] = (Dimension)
377 myrint(sw->scale.scale_y *(y + 1)) - myrint(sw->scale.scale_y * y);
388 sw->scale.rectangles, sw->scale.nrectangles);
390 sw->scale.nrectangles = 0;
401 if (sw->scale.nrectangles == sw->scale.buffer_size)
404 sw->scale.rectangles[(int) sw->scale.nrectangles].x = x;
405 sw->scale.rectangles[(int) sw->scale.nrectangles].y = y;
406 sw->scale.rectangles[(int) sw->scale.nrectangles].width = width;
407 sw->scale.rectangles[(int) sw->scale.nrectangles].height = height;
409 ++sw->scale.nrectangles;
430 img_x = min(max(img_x, 0), (Position) sw->scale.image->width - 1);
431 img_y = min(max(img_y, 0), (Position) sw->scale.image->height - 1);
433 min(img_width, (Dimension)(sw->scale.image->width - (Dimension)img_x));
435 min(img_height, (Dimension)(sw->scale.image->height - (Dimension)img_y));
437 if (sw->scale.scale_x == 1.0 && sw->scale.scale_y == 1.0)
438 XPutImage(XtDisplay(sw), drawable, sw->scale.gc, sw->scale.image,
442 dst_x = dst_x - sw->scale.table.x[(int) img_x];
443 dst_y = dst_y - sw->scale.table.y[(int) img_y];
459 sw->scale.table.x[(int) img_x] + dst_x,
460 sw->scale.table.y[(int) img_y] + dst_y,
461 sw->scale.table.x[(int) img_x + img_width - 1] -
462 sw->scale.table.x[(int) img_x],
463 sw->scale.table.y[(int) img_y + img_height - 1] -
464 sw->scale.table.y[(int) img_y]);
466 if (sw->scale.image->format == XYBitmap) {
469 pixel = XGetPixel(sw->scale.image, x, y);
471 FillRectangle(sw, drawable, sw->scale.gc,
472 sw->scale.table.x[(int) x] + dst_x,
473 sw->scale.table.y[(int) y] + dst_y,
474 sw->scale.table.width[(int) x],
475 sw->scale.table.height[(int) y]);
477 FlushRectangles(sw, drawable, sw->scale.gc);
482 pixel = XGetPixel(sw->scale.image, x, y);
489 sw->scale.table.x[(int) x] + dst_x,
490 sw->scale.table.y[(int) y] + dst_y,
491 sw->scale.table.width[(int) x],
492 sw->scale.table.height[(int) y]);
508 if (*img_x < 0 || *img_x >= sw->scale.image->width
510 *img_y < 0 || *img_y >= sw->scale.image->height)
513 if (sw->scale.table.x[(int) *img_x] >= x) {
517 if (sw->scale.table.x[(int) *img_x] +
518 (Position)sw->scale.table.width[(int) *img_x] < x) {
522 if (sw->scale.table.y[(int) *img_y] >= y) {
526 if (sw->scale.table.y[(int) *img_y] +
527 (Position)sw->scale.table.height[(int) *img_y] < y) {
532 *img_pixel = XGetPixel(sw->scale.image, *img_x, *img_y);
546 x -= sw->scale.x;
547 y -= sw->scale.y;
549 *img_x = (Position) floor(x / sw->scale.scale_x);
550 *img_y = (Position) floor(y / sw->scale.scale_y);
567 if (event->xexpose.x < sw->scale.x) {
570 (sw->scale.x - event->xexpose.x);
573 x = event->xexpose.x - sw->scale.x;
577 if (event->xexpose.y < sw->scale.y) {
580 (sw->scale.y - event->xexpose.y);
583 y = event->xexpose.y - sw->scale.y;
587 img_x = min(max((Position) floor(x / sw->scale.scale_x), 0),
588 (Position) sw->scale.image->width - 1);
590 img_y = min(max((Position) floor(y / sw->scale.scale_y), 0),
591 (Position) sw->scale.image->height - 1);
596 sw->scale.x + sw->scale.table.x[(int) img_x],
597 sw->scale.y + sw->scale.table.y[(int) img_y],
599 / sw->scale.scale_x) + 1,
601 / sw->scale.scale_y) + 1);
616 floor(sw->scale.image->width * sw->scale.scale_x)
617 + 2 * sw->scale.internal_width;
619 floor(sw->scale.image->height * sw->scale.scale_y)
620 + 2 * sw->scale.internal_height;
638 if (sw->scale.scale_x != 1.0)
639 sw->scale.scale_x = floor(sw->scale.scale_x / sw->scale.precision)
640 * sw->scale.precision;
642 if (sw->scale.scale_y != 1.0)
643 sw->scale.scale_y = floor(sw->scale.scale_y / sw->scale.precision)
644 * sw->scale.precision;
655 scale_x = sw->scale.scale_y / sw->scale.aspect_ratio;
656 scale_y = sw->scale.scale_x * sw->scale.aspect_ratio;
658 if (scale_x <= sw->scale.scale_x && scale_y <= sw->scale.scale_y) {
660 sw->scale.scale_x = scale_x;
662 sw->scale.scale_y = scale_y;
664 else if (scale_x <= sw->scale.scale_x)
665 sw->scale.scale_x = scale_x;
666 else if (scale_y <= sw->scale.scale_y)
667 sw->scale.scale_y = scale_y;
671 x_ratio = scale_x / sw->scale.scale_x;
672 y_ratio = scale_y / sw->scale.scale_y;
675 sw->scale.scale_y /= x_ratio;
677 sw->scale.scale_x /= y_ratio;
680 if (fabs(sw->scale.scale_x / sw->scale.scale_y * sw->scale.aspect_ratio
681 - 1.0) > sw->scale.precision)
691 sw->scale.width = (Dimension)
692 max(myrint(sw->scale.scale_x * sw->scale.image->width), 1);
693 sw->scale.height = (Dimension)
694 max(myrint(sw->scale.scale_y * sw->scale.image->height), 1);
707 sw->scale.scale_x =
708 max((int)(sw->core.width - 2 * sw->scale.internal_width), 1)
709 / sw->scale.image->width;
711 sw->scale.scale_y =
712 max((int)(sw->core.height - 2 * sw->scale.internal_height), 1)
713 / sw->scale.image->height;
722 sw->scale.scale_x = sw->scale.scale_y = 1.0;
737 if (sw->scale.proportional) Proportional(sw);
755 sw->scale.x = (Position)
756 (sw->core.width - sw->scale.width) / 2;
757 sw->scale.y = (Position)
758 (sw->core.height - sw->scale.height) / 2;
761 if (sw->scale.gravity & WestGravity) {
763 if (sw->scale.gravity & EastGravity) {
765 if (sw->scale.gravity & NorthGravity) {
767 if (sw->scale.gravity & SouthGravity) {
780 if (sw->scale.autoscale) Autoscale(sw);
793 sw->scale.visual, *vmask, attr);
804 XtFree((char *) sw->scale.table.x);
805 XtFree((char *) sw->scale.table.y);
806 XtFree((char *) sw->scale.table.width);
807 XtFree((char *) sw->scale.table.height);
809 XtFree((char *) sw->scale.rectangles);
811 XtReleaseGC(w, sw->scale.gc);
813 XDestroyImage(sw->scale.image);
831 XSetBackground(XtDisplay(new), new_sw->scale.gc,
835 XSetForeground(XtDisplay(new), new_sw->scale.gc,
836 new_sw->scale.foreground_pixel);
839 XDestroyImage(cur_sw->scale.image);
840 if (new_sw->scale.image == NULL)
841 new_sw->scale.image = XCreateImage(XtDisplay(new),
848 new_sw->scale.image =
849 XSubImage(new_sw->scale.image,
851 new_sw->scale.image->width,
852 new_sw->scale.image->height);
854 if (new_sw->scale.resize)
856 if (new_sw->scale.autoscale)
867 new_sw->scale.userData = (XtPointer)args[i].value;
870 if (new_sw->scale.buffer_size != cur_sw->scale.buffer_size) {
871 GetRectangleBuffer(new_sw, new_sw->scale.buffer_size);
876 if ((new_sw->scale.aspect_ratio =
877 atof(new_sw->scale.aspect_ratio_str)) < 0.0) {
878 new_sw->scale.aspect_ratio = cur_sw->scale.aspect_ratio;
881 else if (new_sw->scale.aspect_ratio != cur_sw->scale.aspect_ratio){
882 if (new_sw->scale.proportional) {
894 if (new_sw->scale.proportional != cur_sw->scale.proportional) {
895 if (new_sw->scale.proportional) Proportional(new_sw);
907 if (new_sw->scale.scale_x_str == DefaultScaleFactor
909 new_sw->scale.scale_y_str == DefaultScaleFactor)
912 if ((new_sw->scale.scale_x =
913 atof(new_sw->scale.scale_x_str)) < 0.0) {
914 new_sw->scale.scale_x = cur_sw->scale.scale_x;
917 if ((new_sw->scale.scale_y =
918 atof(new_sw->scale.scale_y_str)) < 0.0) {
919 new_sw->scale.scale_y = cur_sw->scale.scale_y;
923 if (new_sw->scale.scale_x != cur_sw->scale.scale_x
925 new_sw->scale.scale_y != cur_sw->scale.scale_y) {
929 new_sw->scale.scale_x, new_sw->scale.scale_y);
931 if (new_sw->scale.proportional) Proportional(new_sw);
933 if (new_sw->scale.resize)
943 if ((new_sw->scale.precision =
944 atof(new_sw->scale.precision_str)) < 0.0) {
945 new_sw->scale.precision = cur_sw->scale.precision;
948 if (new_sw->scale.precision != cur_sw->scale.precision) {
949 if (new_sw->scale.proportional) Proportional(new_sw);
1000 if (sw->scale.proportional) Proportional(sw);
1002 if (sw->scale.resize)
1055 sw->scale.width,
1056 sw->scale.height,
1057 sw->scale.image->depth);
1060 (Dimension) sw->scale.image->width,
1061 (Dimension) sw->scale.image->height);