利用QPainter绘制各种图形(Shape, Pen 宽带,颜色,风格,Cap,Join,刷子)
利用QPainter绘制各种图形
Qt的二维图形引擎是基于QPainter类的。QPainter既可以绘制几何形状(点、线、矩形、椭圆、弧形、弦形、饼状图、多边形和贝塞尔曲线),也可以绘制像素映射、图像和文字。此外,QPainter还支持一些高级特性,例如反走样(针对文字和图形边缘)、像素混合、渐变填充和矢量路径等。QPainter也支持线性变换,例如平移、旋转、错切和缩放。
本例子中利用QPainter类提供的各种draw函数,绘制各种类型的图形,包括对图形的形状、颜色、填充风格等的选择。
1、创建paintarea.h
#ifndef PAINTAREA_H
#define PAINTAREA_H
#include <QtGui>
class PaintArea : public QWidget
{
Q_OBJECT
public:
enum Shape {Line,Rectangle,RoundRect,Ellipse,Polygon,Polyline,Points,Arc,Path,Text,Pixmap};
PaintArea(QWidget *parent = 0);
void setShape(Shape);
void setPen(QPen);
void setBrush(QBrush);
void paintEvent(QPaintEvent *);
private:
Shape shape;
QBrush brush;
QPen pen;
};
#endif // PAINTAREA_H
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
2、创建paintarea.cpp文件
#include "paintarea.h"
PaintArea::PaintArea(QWidget *parent) : QWidget(parent)
{
shape = Line;
QPalette p = palette();
p.setColor(QPalette::Window,Qt::white);
setPalette(p);
setAutoFillBackground(true);
setMinimumSize(400,400);
}
void PaintArea::setShape(Shape s)
{
shape = s;
update();
}
void PaintArea::setPen(QPen p)
{
pen = p;
update();
}
void PaintArea::setBrush(QBrush b)
{
brush = b;
update();
}
void PaintArea::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.setPen(pen);
p.setBrush(brush);
QRect rect(50,100,300,200);
static const QPoint points[4] = {
QPoint(150,100),
QPoint(300,150),
QPoint(350,250),
QPoint(100,300)
};
int startAngle = 30 * 16;
int spanAngle = 120 * 16;
QPainterPath path;
path.addRect(150,150,100,100);
path.moveTo(100,100);
path.cubicTo(300,100,200,200,300,300);
path.cubicTo(100,300,200,200,100,100);
switch(shape)
{
case Line:
p.drawLine(rect.topLeft(),rect.bottomRight());
break;
case Rectangle:
p.drawRect(rect);
break;
case RoundRect:
p.drawRoundRect(rect);
break;
case Ellipse:
p.drawEllipse(rect);
break;
case Polygon:
p.drawPolygon(points,4);
break;
case Polyline:
p.drawPolyline(points,4);
break;
case Points:
p.drawPoints(points,4);
break;
case Arc:
p.drawArc(rect,startAngle,spanAngle);
break;
case Path:
p.drawPath(path);
break;
case Text:
p.drawText(rect,Qt::AlignCenter,tr("Hello Qt"));
break;
case Pixmap:
p.drawPixmap(150,150,QPixmap(":/images/butterfly.png"));
break;
default:
break;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
3、创建mainwidget.h
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include <QtGui>
#include "paintarea.h"
class MainWidget : public QWidget
{
Q_OBJECT
public:
MainWidget(QWidget *parent = 0);
public slots:
void slotShape(int);
void slotPenWidth(int);
void slotPenColor();
void slotPenStyle(int);
void slotPenCap(int);
void slotPenJoin(int);
void slotBrush(int);
private:
PaintArea *area;
QComboBox *shapeComboBox;
QSpinBox *widthSpinBox;
QComboBox *penStyleComboBox;
QComboBox *penCapComboBox;
QComboBox *penJoinComboBox;
QComboBox *brushStyleComboBox;
QFrame *colorFrame;
};
#endif // MAINWIDGET_H
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
4、创建mainwidget.cpp
#include "mainwidget.h"
MainWidget::MainWidget(QWidget *parent) : QWidget(parent)
{
area = new PaintArea;
QLabel *label1 = new QLabel(tr("Shape:"));
QLabel *label2 = new QLabel(tr("Pen Width:"));
QLabel *label3 = new QLabel(tr("Pen Color:"));
QLabel *label4 = new QLabel(tr("Pen Style:"));
QLabel *label5 = new QLabel(tr("Pen Cap:"));
QLabel *label6 = new QLabel(tr("Pen Join:"));
QLabel *label7 = new QLabel(tr("Brush:"));
shapeComboBox = new QComboBox;
shapeComboBox->addItem(tr("Line"), PaintArea::Line);
shapeComboBox->addItem(tr("Polygon"), PaintArea::Polygon);
shapeComboBox->addItem(tr("Rectangle"), PaintArea::Rectangle);
shapeComboBox->addItem(tr("Round Rectangle"), PaintArea::RoundRect);
shapeComboBox->addItem(tr("Ellipse"), PaintArea::Ellipse);
shapeComboBox->addItem(tr("Path"), PaintArea::Path);
shapeComboBox->addItem(tr("Polyline"), PaintArea::Polyline);
shapeComboBox->addItem(tr("Arc"), PaintArea::Arc);
shapeComboBox->addItem(tr("Points"), PaintArea::Points);
shapeComboBox->addItem(tr("Text"), PaintArea::Text);
shapeComboBox->addItem(tr("Pixmap"), PaintArea::Pixmap);
connect(shapeComboBox,SIGNAL(activated(int)),this,SLOT(slotShape(int)));
widthSpinBox = new QSpinBox;
widthSpinBox->setRange(0,20);
connect(widthSpinBox,SIGNAL(valueChanged(int)),this,SLOT(slotPenWidth(int)));
colorFrame = new QFrame;
colorFrame->setAutoFillBackground(true);
colorFrame->setPalette(QPalette(Qt::blue));
QPushButton *colorPushButton = new QPushButton(tr("change"));
connect(colorPushButton,SIGNAL(clicked()),this,SLOT(slotPenColor()));
penStyleComboBox = new QComboBox;
penStyleComboBox->addItem(tr("Solid"), Qt::SolidLine);
penStyleComboBox->addItem(tr("Dash"), Qt::DashLine);
penStyleComboBox->addItem(tr("Dot"), Qt::DotLine);
penStyleComboBox->addItem(tr("Dash Dot"), Qt::DashDotLine);
penStyleComboBox->addItem(tr("Dash Dot Dot"), Qt::DashDotDotLine);
penStyleComboBox->addItem(tr("None"), Qt::NoPen);
connect(penStyleComboBox,SIGNAL(activated(int)),this,SLOT(slotPenStyle(int)));
penCapComboBox = new QComboBox;
penCapComboBox->addItem(tr("Flat"), Qt::FlatCap);
penCapComboBox->addItem(tr("Square"), Qt::SquareCap);
penCapComboBox->addItem(tr("Round"), Qt::RoundCap);
connect(penCapComboBox,SIGNAL(activated(int)),this,SLOT(slotPenCap(int)));
penJoinComboBox = new QComboBox;
penJoinComboBox->addItem(tr("Miter"), Qt::MiterJoin);
penJoinComboBox->addItem(tr("Bevel"), Qt::BevelJoin);
penJoinComboBox->addItem(tr("Round"), Qt::RoundJoin);
connect(penJoinComboBox,SIGNAL(activated(int)),this,SLOT(slotPenJoin(int)));
brushStyleComboBox = new QComboBox;
brushStyleComboBox->addItem(tr("Linear Gradient"),
Qt::LinearGradientPattern);
brushStyleComboBox->addItem(tr("Radial Gradient"),
Qt::RadialGradientPattern);
brushStyleComboBox->addItem(tr("Conical Gradient"),
Qt::ConicalGradientPattern);
brushStyleComboBox->addItem(tr("Texture"), Qt::TexturePattern);
brushStyleComboBox->addItem(tr("Solid"), Qt::SolidPattern);
brushStyleComboBox->addItem(tr("Horizontal"), Qt::HorPattern);
brushStyleComboBox->addItem(tr("Vertical"), Qt::VerPattern);
brushStyleComboBox->addItem(tr("Cross"), Qt::CrossPattern);
brushStyleComboBox->addItem(tr("Backward Diagonal"), Qt::BDiagPattern);
brushStyleComboBox->addItem(tr("Forward Diagonal"), Qt::FDiagPattern);
brushStyleComboBox->addItem(tr("Diagonal Cross"), Qt::DiagCrossPattern);
brushStyleComboBox->addItem(tr("Dense 1"), Qt::Dense1Pattern);
brushStyleComboBox->addItem(tr("Dense 2"), Qt::Dense2Pattern);
brushStyleComboBox->addItem(tr("Dense 3"), Qt::Dense3Pattern);
brushStyleComboBox->addItem(tr("Dense 4"), Qt::Dense4Pattern);
brushStyleComboBox->addItem(tr("Dense 5"), Qt::Dense5Pattern);
brushStyleComboBox->addItem(tr("Dense 6"), Qt::Dense6Pattern);
brushStyleComboBox->addItem(tr("Dense 7"), Qt::Dense7Pattern);
brushStyleComboBox->addItem(tr("None"), Qt::NoBrush);
connect(brushStyleComboBox,SIGNAL(activated(int)),this,SLOT(slotBrush(int)));
QGridLayout *ctrlLayout = new QGridLayout;
int labelCol = 0;
int contentCol = 1;
ctrlLayout->addWidget(label1,0,labelCol);
ctrlLayout->addWidget(shapeComboBox,0,contentCol);
ctrlLayout->addWidget(label2,1,labelCol);
ctrlLayout->addWidget(widthSpinBox,1,contentCol);
ctrlLayout->addWidget(label3,2,labelCol);
ctrlLayout->addWidget(colorFrame,2,contentCol);
ctrlLayout->addWidget(colorPushButton,2,2);
ctrlLayout->addWidget(label4,3,labelCol);
ctrlLayout->addWidget(penStyleComboBox,3,contentCol);
ctrlLayout->addWidget(label5,4,labelCol);
ctrlLayout->addWidget(penCapComboBox,4,contentCol);
ctrlLayout->addWidget(label6,5,labelCol);
ctrlLayout->addWidget(penJoinComboBox,5,contentCol);
ctrlLayout->addWidget(label7,6,labelCol);
ctrlLayout->addWidget(brushStyleComboBox,6,contentCol);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(area);
mainLayout->addLayout(ctrlLayout);
mainLayout->setMargin(10);
mainLayout->setSpacing(10);
setLayout(mainLayout);
slotShape(0);
slotPenWidth(0);
slotPenStyle(0);
slotPenCap(0);
slotPenJoin(0);
slotBrush(0);
}
void MainWidget::slotShape(int value)
{
PaintArea::Shape shape = PaintArea::Shape(shapeComboBox->itemData(value,Qt::UserRole).toInt());
area->setShape(shape);
}
void MainWidget::slotPenWidth(int value)
{
QColor color = colorFrame->palette().color(QPalette::Window);
Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData(
penStyleComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData(
penCapComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData(
penJoinComboBox->currentIndex(), Qt::UserRole).toInt());
area->setPen(QPen(color, value, style, cap, join));
}
void MainWidget::slotPenColor()
{
QColor color = QColorDialog::getColor(Qt::blue);
colorFrame->setPalette(QPalette(color));
int width = widthSpinBox->value();
Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData(
penStyleComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData(
penCapComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData(
penJoinComboBox->currentIndex(), Qt::UserRole).toInt());
area->setPen(QPen(color, width, style, cap, join));
}
void MainWidget::slotPenStyle(int value)
{
int width = widthSpinBox->value();
QColor color = colorFrame->palette().color(QPalette::Window);
Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData(value, Qt::UserRole).toInt());
Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData(
penCapComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData(
penJoinComboBox->currentIndex(), Qt::UserRole).toInt());
area->setPen(QPen(color, width, style, cap, join));
}
void MainWidget::slotPenCap(int value)
{
int width = widthSpinBox->value();
QColor color = colorFrame->palette().color(QPalette::Window);
Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData(
penStyleComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData(value, Qt::UserRole).toInt());
Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData(
penJoinComboBox->currentIndex(), Qt::UserRole).toInt());
area->setPen(QPen(color, width, style, cap, join));
}
void MainWidget::slotPenJoin(int value)
{
int width = widthSpinBox->value();
QColor color = colorFrame->palette().color(QPalette::Window);
Qt::PenStyle style = Qt::PenStyle(penStyleComboBox->itemData(
penStyleComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenCapStyle cap = Qt::PenCapStyle(penCapComboBox->itemData(
penCapComboBox->currentIndex(), Qt::UserRole).toInt());
Qt::PenJoinStyle join = Qt::PenJoinStyle(penJoinComboBox->itemData(value, Qt::UserRole).toInt());
area->setPen(QPen(color, width, style, cap, join));
}
void MainWidget::slotBrush(int value)
{
Qt::BrushStyle style = Qt::BrushStyle(brushStyleComboBox->itemData(value, Qt::UserRole).toInt());
if (style == Qt::LinearGradientPattern) {
QLinearGradient linearGradient(0, 0, 400, 400);
linearGradient.setColorAt(0.0, Qt::white);
linearGradient.setColorAt(0.2, Qt::green);
linearGradient.setColorAt(1.0, Qt::black);
area->setBrush(linearGradient);
} else if (style == Qt::RadialGradientPattern) {
QRadialGradient radialGradient(200, 200, 150, 150, 100);
radialGradient.setColorAt(0.0, Qt::white);
radialGradient.setColorAt(0.2, Qt::green);
radialGradient.setColorAt(1.0, Qt::black);
area->setBrush(radialGradient);
} else if (style == Qt::ConicalGradientPattern) {
QConicalGradient conicalGradient(200, 200, 30);
conicalGradient.setColorAt(0.0, Qt::white);
conicalGradient.setColorAt(0.2, Qt::green);
conicalGradient.setColorAt(1.0, Qt::black);
area->setBrush(conicalGradient);
} else if (style == Qt::TexturePattern) {
area->setBrush(QBrush(QPixmap(":/images/cheese.jpg")));
} else {
area->setBrush(QBrush(Qt::green, style));
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
5、创建资源文件paintbasic.qrc
6、创建main.cpp
#include <QApplication>
#include "mainwidget.h"
int main(int argc, char * argv[])
{
QApplication app(argc,argv);
MainWidget w;
w.show();
return app.exec();
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
6、编译运行
7、资源代码文件
https://blog.csdn.net/onlyshi/article/details/47953849
利用QPainter绘制各种图形(Shape, Pen 宽带,颜色,风格,Cap,Join,刷子)的更多相关文章
- PyQt5利用QPainter绘制各种图形
这个例子我做了好几天: 1)官网C++的源码,改写成PyQt5版本的代码,好多细节不会转化 2)网上的PyQt的例子根本运行不了 填了无数个坑,结合二者,终于能完成了一个关于绘图的东西.这个过程也掌握 ...
- 利用QPainter绘制散点图
[1]实例代码 (1)代码目录结构(备注:QtCreator默认步骤新建工程) (2)工程pro文件 QT += core gui greaterThan(QT_MAJOR_VERSION, ): Q ...
- 利用Turtle绘制各种图形
首先引入函数库: 第一种: import turtle import turtle as t 第二种: from turtle import * 1:使用 turtle 库的 turtle.fd() ...
- 利用PowerDesigner绘制PDM生成SQL Server数据库
PowerDesigner是个很强大的建模工具,可以利用它绘制各种图形,本文利用该工具绘制PDM,进而生成SQL Server数据库. 比如绘制一个简单的学生选课.教师授课管理系统的PDM: pk表示 ...
- 利用 turtle库绘制简单图形
turtle库是python的基础绘图库,这个库被介绍为一个最常用的用来介绍编程知识的方法库,其主要是用于程序设计入门,是标准库之一,利用turtle可以制作很多复杂的绘图. turtle名称含义为“ ...
- css绘制特殊图形,meida查询,display inline-box间隙问题以及calc()函数
本文同时发表于本人个人网站 www.yaoxiaowen.com 距离上一篇文章已经一个月了,相比于写代码,发现写文章的确是更需要坚持的事情.言归正传,梳理一下这一个月来,在写ife任务时,有必要记录 ...
- css绘制特殊图形,meida查询,display inline-box间隙问题以及calc()函数
本文同时发表于本人个人网站 www.yaoxiaowen.com 距离上一篇文章已经一个月了,相比于写代码,发现写文章的确是更需要坚持的事情.言归正传,梳理一下这一个月来,在写ife任务时,有必要记录 ...
- 学习笔记:HTML5 Canvas绘制简单图形
HTML5 Canvas绘制简单图形 1.添加Canvas标签,添加id供js操作. <canvas id="mycanvas" height="700" ...
- C#利用GDI+绘制旋转文字等效果
C#中利用GDI+绘制旋转文本的文字,网上有很多资料,基本都使用矩阵旋转的方式实现.但基本都只提及按点旋转,若要实现在矩形范围内旋转文本,资料较少.经过琢磨,可以将矩形内旋转转化为按点旋转,不过需要经 ...
随机推荐
- web.xml的配置及加载顺序
一web.xml加载过程(步骤): 1.启动WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> ...
- 洛谷 P1416 攻击火星
P1416 攻击火星 题目描述 一群外星人将要攻击火星. 火星的地图是一个n个点的无向图.这伙外星人将按照如下方法入侵,先攻击度为0的点(相当于从图中删除掉它),然后是度为1的点,依此类推直到度为n- ...
- 【MapReduce】经常使用计算模型具体解释
前一阵子參加炼数成金的MapReduce培训,培训中的作业样例比較有代表性,用于解释问题再好只是了. 有一本国外的有关MR的教材,比較有用.点此下载. 一.MapReduce应用场景 MR能解决什么问 ...
- 90.#define高级用法
define把参数变成字符串 #define f(x) printf("%s",#x); define连接两个字符串 #define a(x) a##x define把参数变成字符 ...
- WINWORD.EXE-损坏的图像
问题详情: 系统键 + R键,运行 再输入regedit HKEY_CLASSES_ROOT\.docx HKEY_CLASSES_ROOT\Word.Document.12 HKEY_CURREN ...
- js进阶 13-6 jquery动画效果相关常用函数有哪些
js进阶 13-6 jquery动画效果相关常用函数有哪些 一.总结 一句话总结:animate(),stop(),finish(),delat()四个. 1.stop()方法的基本用法是什么(sto ...
- (转)c运行库、c标准库、windows API的区别和联系
C运行时库函数C运行时库函数是指C语言本身支持的一些基本函数,通常是汇编直接实现的. API函数API函数是操作系统为方便用户设计应用程序而提供的实现特定功能的函数,API函数也是C语言的函数实现的 ...
- 【例题 6-5 UVA 12657 】Boxes in a Line
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 双向链表模拟题. 移动的时候,要注意它就在所需要的位置的情况.那种情况不移动. (如果已经在所需位置了,还用链表的插入方式强行移动的 ...
- Android中各种drawable的使用
转载请说明出处.本文来自Android菜鸟:http://blog.csdn.net/android_cai_niao/article/details/46854767 QQ:2717521606 ...
- Caffe 学习:Crop 层
在Fully Convolutional Networks(FCN)中,会用到Crop 层,他的主要作用是进行裁切.下面我们举一个例子来说明如何使用Crop 层. Caffe中的数据是以 blobs形 ...