当前位置: 首页>>代码示例>>C++>>正文


C++ PNG::resize方法代码示例

本文整理汇总了C++中PNG::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ PNG::resize方法的具体用法?C++ PNG::resize怎么用?C++ PNG::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PNG的用法示例。


在下文中一共展示了PNG::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{
	const int canvas_width = 128;
	const int canvas_height = 128;

	PNG canvas;
	canvas.resize(canvas_width, canvas_height);


	const RGBAPixel triangle_color = color::ORANGE;
	Shape* triangle = new Triangle(triangle_color,
			Vector2(32, 32),
			Vector2(64, 64),
			Vector2(32, 64));

	triangle->draw(&canvas);

	canvas.writeToFile("test_destructor.png");

	/* TODO: Why is this leaking memory?  Triangle does have a valid destructor!?
	 * Can you stop it from leaking WITHOUT changing triangle's type from a
	 * Shape pointer to a Triangle pointer type? */
	delete triangle;
	triangle = NULL;

	return 0;
}
开发者ID:irtefa,项目名称:dumbshit,代码行数:27,代码来源:test_destructor.cpp

示例2: main

int main(int argc, char* argv[])
{
	const int canvas_width = 128;
	const int canvas_height = 128;

	PNG canvas;
	canvas.resize(canvas_width, canvas_height);

	Vector2 rectangle_center(canvas_width / 2, canvas_height / 2);
	const int rectangle_width = canvas_width / 4;
	const int rectangle_height = canvas_height / 4;
	Rectangle* rectangle = new Rectangle(rectangle_center,
			color::BLUE,
			rectangle_width,
			rectangle_height);

	rectangle->draw(&canvas);

	const int rectangle_perimeter = rectangle->perimeter();
	cout << "Rectangle's Perimeter = " << rectangle_perimeter << endl;
	const int rectangle_area = rectangle->area();
	cout << "Rectangle's Area = " << rectangle_area << endl;

	/* But we can treat a Rectangle just like a Shape using a Shape pointer */
	Shape* shape = rectangle;
	const int shape_perimeter = shape->perimeter();
	cout << "Shape's Perimeter = " << shape_perimeter << endl;
	const int shape_area = shape->area();
	cout << "Shape' Area = " << shape_area << endl;

	/* TODO: For some reason the shape's area and perimeter is different from
	 * triangle's area and perimeter even though they are pointing to the same
	 * object!  Can you this this so they are the same WITHOUT changing the
	 * shape's type from a Shape pointer to a Triangle pointer? */
	if (rectangle_perimeter == shape_perimeter)
	{
		cout << "The Perimeters are the same!" << endl;
	} else
	{
		
		cout << "The Perimeters are NOT the same." << endl;
	}

	if (rectangle_area == shape_area)
	{
		cout << "The Areas are the same!" << endl;
	} else
	{
		cout << "The Areas are NOT the same." << endl;
	}

	canvas.writeToFile("test_virtual.png");

	delete rectangle;

	return 0;
}
开发者ID:guptadipanshu,项目名称:Data_structure,代码行数:57,代码来源:test_virtual.cpp

示例3: main

int main()
{
    const int rectangle_width = 16;
    const int rectangle_height = 16;
    Vector2 rectangle_center(32, 16);
    // I can create a Rectangle using a Rectangle Pointer!
    Rectangle* rectangle = new Rectangle(rectangle_center, color::RED,
                                         rectangle_width, rectangle_height);

    rectangle_center.set_x(rectangle_center.x() + rectangle_width);
    // OR I can create a Rectangle using a Shape Pointer!!
    Shape* rectangle_shape = new Rectangle(rectangle_center, color::ORANGE,
                                           rectangle_width, rectangle_height);

    rectangle_center.set_x(rectangle_center.x() + rectangle_width);
    // OR I can create a Rectangle using a Drawable Pointer!!!
    Drawable* rectangle_drawable = new Rectangle(
        rectangle_center, color::YELLOW, rectangle_width, rectangle_height);

    // Since all these pointers point to something that is a Drawable type
    // lets make an array of drawable pointers
    size_t num_drawables = 3;
    Drawable** drawables = new Drawable*[num_drawables];
    drawables[0] = rectangle;
    drawables[1] = rectangle_shape;
    drawables[2] = rectangle_drawable;

    PNG canvas;
    canvas.resize(WIDTH, HEIGHT);

    // Since they are all drawable I can call draw on all of them
    for (size_t i = 0; i < num_drawables; i++) {
        drawables[i]->draw(&canvas);
    }

    canvas.writeToFile(OUTPUT_FILE);

    for (size_t i = 0; i < num_drawables; i++) {
        delete drawables[i];
        drawables[i] = NULL;
    }

    delete[] drawables;
    drawables = NULL;
    return 0;
}
开发者ID:liu298,项目名称:DataStructure-Lab,代码行数:46,代码来源:main.cpp

示例4: testColorPicker

PNG testColorPicker(colorPicker & picker) {
	PNG img;
	img.resize(FUNCTORTESTWIDTH, FUNCTORTESTHEIGHT);
	RGBAPixel px;

	for(int x = 1; x < FUNCTORTESTWIDTH; x = x + x)
	{
		for(int y = 1; y < FUNCTORTESTHEIGHT; y = y + y) {
			px = picker(x, y);
			cout << "\toperator()(" << x << ", " << y << ") = {" << (int)px.red << ", ";
			cout << (int)px.green << ", " << (int)px.blue << "}" << endl;
		}
	}

	for(int x = 0; x < FUNCTORTESTWIDTH; x++)
		for(int y = 0; y < FUNCTORTESTHEIGHT; y++)
			*img(x, y) = picker(x, y);

	return img;
}
开发者ID:Arkhtyi,项目名称:Discrete-structures,代码行数:20,代码来源:testFills.cpp


注:本文中的PNG::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。