コード例 #1
0
ファイル: image_filters.cpp プロジェクト: foogywoo/drone
    void on_idle()
    {
        if(m_run.status())
        {
            if(m_cur_angle < 360.0)
            {
                m_cur_angle += m_step.value();
                copy_img_to_img(1, 0);
#ifdef AGG_ACCURATE_TIME
                start_timer();
#endif
                transform_image(m_step.value());
#ifdef AGG_ACCURATE_TIME
                m_time2 += elapsed_time();
#endif
                m_num_steps++;
            }
            else
            {
                m_cur_angle = 0.0;
#ifndef AGG_ACCURATE_TIME
                m_time2 = clock();
#endif
                wait_mode(true);
                m_run.status(false);
            }
            force_redraw();
        }
        else
        {
            wait_mode(true);
        }
    }
コード例 #2
0
ファイル: image_filters.cpp プロジェクト: foogywoo/drone
    void on_ctrl_change()
    {
        if(m_single_step.status())
        {
            m_cur_angle += m_step.value();
            copy_img_to_img(1, 0);
            transform_image(m_step.value());
            m_num_steps++;
            force_redraw();
            m_single_step.status(false);
        }

        if(m_run.status())
        {
#ifdef AGG_ACCURATE_TIME
            start_timer();
            m_time1 = m_time2 = elapsed_time();
#else
            m_time1 = m_time2 = clock();
#endif
            m_num_pix = 0.0;
            wait_mode(false);
        }
        if(m_refresh.status() || m_filters.cur_item() != m_cur_filter)
        {
#ifdef AGG_ACCURATE_TIME
            start_timer();
            m_time1 = m_time2 = 0;
#else
            m_time1 = m_time2 = clock();
#endif
            m_num_pix = 0.0;
            m_cur_angle = 0.0;
            copy_img_to_img(1, 2);
            transform_image(0.0);
            m_refresh.status(false);
            m_cur_filter = m_filters.cur_item();
            m_num_steps = 0;
            force_redraw();
        }
    }
コード例 #3
0
extern "C" void gxpport_render_immutableregion
(gxpport_image_native_handle immutableImagePtr,
 gxpport_mutableimage_native_handle dstMutableImagePtr,
 const jshort *clip,
 jint x_dest, jint y_dest, 
 jint width, jint height,
 jint x_src, jint y_src,
 jint transform) {

    _Platform_ImmutableImage* immutableImage = 
        (_Platform_ImmutableImage*)immutableImagePtr;
    QPixmap *qpixmapDst =
    gxpportqt_get_mutableimage_pixmap(dstMutableImagePtr);

    if (NULL == immutableImagePtr || immutableImage->qimage->isNull()) {
      /* not a valid image should not happen, log this */
        return;
    }

    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(-1, -1, clip, 
                                    (QPaintDevice *)qpixmapDst, 
                                    0);
    if (0 == transform) {
        gc->drawImage(x_dest, y_dest,
                      *immutableImage->qimage,
                      x_src, y_src,
                      width, height,
                      0);
        return;
    }

    QImage image = immutableImage->qimage->copy(x_src, y_src, 
                                               width, height);

    transform_image(&image, transform);
    
    if (!image.isNull()) {
        gc->drawImage(x_dest, y_dest, image);
    }
}
コード例 #4
0
extern "C" void gxpport_createimmutable_from_mutableregion
(gxpport_mutableimage_native_handle srcMutableImagePtr,
 int src_x, int src_y, 
 int src_width, int src_height,
 int transform,
 gxpport_image_native_handle* newImmutableImagePtr,
 gxutl_native_image_error_codes* creationErrorPtr) {

    QPixmap *srcqpixmap =
    gxpportqt_get_mutableimage_pixmap(srcMutableImagePtr);

    int rscSize = ImgRegionRscSize(srcqpixmap, src_width, src_height);

    /* Check resource limit */
    if (midpCheckResourceLimit(RSC_TYPE_IMAGE_IMMUT, rscSize) == 0) {
        /* Exceed Resource limit */
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_RESOURCE_LIMIT;
        return;
    }

    QImage srcQImage = srcqpixmap->convertToImage();
    if (srcQImage.isNull()) {
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;
    }

    _Platform_ImmutableImage* immutableImage = 
      (_Platform_ImmutableImage*)midpMalloc(sizeof(_Platform_ImmutableImage));
    if (immutableImage == NULL) {
	*creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
	return;
    }

    immutableImage->qimage = new QImage(srcQImage.copy(src_x,
                                                       src_y, 
                                                       src_width, 
                                                       src_height));
    if (NULL == immutableImage->qimage) {
	midpFree(immutableImage);
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;
    }

    if (immutableImage->qimage->isNull()) {
        delete immutableImage->qimage;
	midpFree(immutableImage);
        *creationErrorPtr = GXUTL_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR;
        return;
    }

    if (transform != 0) {
        transform_image(immutableImage->qimage, transform);
    }

    /* Copy succeeds */
    if (midpIncResourceCount(RSC_TYPE_IMAGE_IMMUT, rscSize) == 0) {
        REPORT_ERROR(LC_LOWUI, "Error in updating resource limit"
                     " for Immutable image");
    }

    immutableImage->marker = 3;
    immutableImage->qpixmap = NULL;
    
    *newImmutableImagePtr = immutableImage;
    *creationErrorPtr = GXUTL_NATIVE_IMAGE_NO_ERROR;
}
コード例 #5
0
ファイル: ppmtrans.c プロジェクト: aholton001/Comp-40
/*                                 main()
 *
 * Main function for the program reads in an image from the command line or from
 * stdin, as well as any specifications the user provided for a storage method
 * and/or desired rotation. Calls helper functions to perform the proper
 * rotation on the image and prints the final image to stdout in the ppm format.
 */
int main(int argc, char *argv[]) 
{
        int i;
        int rotation = 0;
	FILE *srcfile;
 	Pnm_ppm original_image;
	Pnm_ppm transformed_image;

        /* default to UArray2 methods */
        A2Methods_T methods = uarray2_methods_plain; 
        assert(methods);

        /* default to best map */
        A2Methods_mapfun *map = methods->map_default; 
        assert(map);

#define SET_METHODS(METHODS, MAP, WHAT) do {                            \
                methods = (METHODS);                                    \
                assert(methods != NULL);                                \
                map = methods->MAP;                                     \
                if (map == NULL) {                                      \
                        fprintf(stderr, "%s does not support "          \
                                        WHAT "mapping\n",               \
                                argv[0]);                               \
                        exit(1);                                        \
                }                                                       \
        } while (0)

	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-row-major")) {
			SET_METHODS(uarray2_methods_plain, map_row_major,
				    "row-major");
		} else if (!strcmp(argv[i], "-col-major")) {
			SET_METHODS(uarray2_methods_plain, map_col_major,
				    "column-major");
		} else if (!strcmp(argv[i], "-block-major")) {
			SET_METHODS(uarray2_methods_blocked, map_block_major,
				    "block-major");
		} else if (!strcmp(argv[i], "-rotate")) {
			if (!(i + 1 < argc)) {      /* no rotate value */
				usage(argv[0]);
			}
			char *endptr;
			rotation = strtol(argv[++i], &endptr, 10);
			if (!(rotation == 0 || rotation == 90
			      || rotation == 180 || rotation == 270)) {
				fprintf(stderr, "Rotation must be "
					"0, 90 180 or 270\n");
				usage(argv[0]);
				exit(EXIT_FAILURE);
			}
			if (!(*endptr == '\0')) {    /* Not a number */
				usage(argv[0]);
			      	exit(EXIT_FAILURE);
			}
		} else if (*argv[i] == '-') {
			fprintf(stderr, "%s: unknown option '%s'\n", argv[0],
				argv[i]);
			exit(EXIT_FAILURE);
		} else if (argc - i > 1) {
			fprintf(stderr, "Too many arguments\n");
			usage(argv[0]);
		} else {
			break;
		}
	}
	
	if (i < argc) {
                srcfile = fopen (argv[i], "rb");
                assert(srcfile != NULL);
        }
        else {
                srcfile = stdin;
                assert(srcfile != NULL);
        }
	original_image = Pnm_ppmread (srcfile, methods);
  
        if (rotation == 0) {
                Pnm_ppmwrite(stdout, original_image);
                Pnm_ppmfree(&original_image);
        }
        else{
                transformed_image = transform_image (rotation, original_image, 
                                                     map, methods);
                Pnm_ppmwrite(stdout, transformed_image);        
                Pnm_ppmfree(&original_image);
                Pnm_ppmfree(&transformed_image);
        }
        fclose(srcfile);
	exit (EXIT_SUCCESS);
}