示例#1
0
void save_bitmap(const char *filename)
{
	int r,be;
	r = access(filename,0);
	if( r == 0)
	{
		top_message("file already exists,Overwriting");
	}
		hidemouseptr();
		top_panel_default();
		setcolor(RED);
		outtextxy(200,3,"Please Wait");
		prgx=1;
		setcolor(BLACK);
		rectangle(0,2,ymax,18);
		be = writeBitmapFile(0,0,filename);
		showmouseptr();
		if( be != 0)
		{
		   top_message("Error While Creating File");
		   return;
		}
		else
		      {
		      top_message("File saved successfully");
		      }
	return;
}
示例#2
0
文件: main.c 项目: syakesaba/Myn900
void run()
{
	cl_int retval;
	void *destination_data = NULL;
	const int work_dimensions = 2;
	size_t image_dimensions[3] = { bitmapwidth, bitmapheight, 0 };
	size_t image_origin[3] = { 0, 0, 0 };
	size_t image_pitch = 0;


	// set kernel arguments. these match the kernel function declaration
	clSetKernelArg(kernel, 0, sizeof(cl_mem), &srcimage);
	clSetKernelArg(kernel, 1, sizeof(cl_mem), &destimage);


	// execute the kernel function
	printf("Applying function '%s' to image\n", kernel_fn_name);

	// 1st param: command queue
	// 2nd param: kernel to execute
	// 3rd param: amount of work dimensions to use (1-3)
	// 4th param: global work offset, not used, set to NULL
	// 5th param: global work size, work dimension range
	// 6th param: local work size, or NULL if OpenCL divides global work size to local
	// 7th param: num events in wait list
	// 8th param: event wait list
	// 9th param: event
	clEnqueueNDRangeKernel(	command_queue,
							kernel,
							work_dimensions,
							NULL,
							image_dimensions,
							NULL,
							0,
							NULL,
							NULL);


	// add image data mapping to command queue
	// image data must be mapped to access it

	// 1st param: command queue
	// 2nd param: image to map
	// 3rd param: run blocking or in non-blocking mode
	// 4th param: image origin to map from
	// 5th param: image dimensions to map
	// 6th param: mapped horline size
	// 7th param: mapped 3D image slice size
	// 8th param: num events in wait list
	// 9th param: event wait list
	// 10th param: event
	// 11th param: error code on return, or NULL if not used
	destination_data = clEnqueueMapImage(	command_queue,
											destimage,
											CL_FALSE,
											CL_MAP_READ,
											image_origin,
											image_dimensions,
											&image_pitch,
											NULL,
											0,
											NULL,
											NULL,
											&retval);


	// run queue until all items are finished
	clFinish(command_queue);

	// write destination image data to bitmap file
	const char *output_name = "output.bmp";
	writeBitmapFile(output_name, destination_data, bitmapwidth, bitmapheight);
	printf("Wrote image '%s'\n", output_name);

	// unmap destination image

	// 1st param: command queue
	// 2nd param: image to unmap
	// 3rd param: pointer received from mapping function
	// 4th param: num events in wait list
	// 5th param: event wait list
	// 6th param: event
	clEnqueueUnmapMemObject(	command_queue,
								destimage,
								destination_data,
								0,
								NULL,
								NULL);

	// run queue until all items are finished
	clFinish(command_queue);

	printf("All done.\n");
}