QPixmap buffer
(pixMap
->rect
().
width(),pixMap
->height
() );
//painter.scale(mapScale,mapScale);
int cX = pixMap->width()/2;
int cZ = pixMap->height()/2;
//myPlayer.curPos.x = myX;
//myPlayer.curPos.z = myZ;
int cMapX = pixMap->width()/2;
int cMapY = pixMap->height()/2;
int gamePointX=0;
int gamePointZ=0;
recvMap.setLeft( gamePointX + cMapX + (myX - cX/mapScale)/scale );
recvMap.setRight( gamePointX + cMapX + (myX + cX/mapScale)/scale);
recvMap.setTop( gamePointZ + cMapY - (myZ + cZ/mapScale)/scale);
recvMap.setBottom( gamePointZ + cMapY - (myZ - cZ/mapScale)/scale);
painter.
setRenderHint(QPainter::Antialiasing,
true);
QRectF srcRect
=pixMap
->rect
();
painter.
fillRect(rect
(),
QBrush(Qt
::black));
painterBuffer.
drawPixmap(QPointF(1,
1),
*pixMap,recvMap
);
buffer.scaled(512,512,Qt::KeepAspectRatio);
painter.save();
painter.
drawPixmap(QPointF(1,
1),buffer,buffer.
rect());
painter.restore();
painter.setPen(Qt::white);
font.setPointSize(24);
painter.setFont(font);
int fontHeigh = fm.height();
tmp.sprintf("%.0f %.0f",mouseMovePos.x(),mouseMovePos.y());
//painter.drawText(0,fontHeigh,tr("%1,%2").arg(mouseMovePos.x()).arg(mouseMovePos.y()));
painter.drawText(0,fontHeigh,tmp);
tmp.clear();
tmp.sprintf("My Pos %d %d",myX,myZ);
painter.drawText(0,fontHeigh*2,tmp);
QPixmap buffer(pixMap->rect().width(),pixMap->height() );
QPainter painterBuffer(&buffer);
QPainter painter(this);
//painter.scale(mapScale,mapScale);
int cX = pixMap->width()/2;
int cZ = pixMap->height()/2;
//myPlayer.curPos.x = myX;
//myPlayer.curPos.z = myZ;
int cMapX = pixMap->width()/2;
int cMapY = pixMap->height()/2;
int gamePointX=0;
int gamePointZ=0;
QRect recvMap;
recvMap.setLeft( gamePointX + cMapX + (myX - cX/mapScale)/scale );
recvMap.setRight( gamePointX + cMapX + (myX + cX/mapScale)/scale);
recvMap.setTop( gamePointZ + cMapY - (myZ + cZ/mapScale)/scale);
recvMap.setBottom( gamePointZ + cMapY - (myZ - cZ/mapScale)/scale);
painter.setRenderHint(QPainter::Antialiasing,true);
QRectF srcRect=pixMap->rect();
painter.fillRect(rect(),QBrush(Qt::black));
painterBuffer.drawPixmap(QPointF(1,1),*pixMap,recvMap);
buffer.scaled(512,512,Qt::KeepAspectRatio);
painter.save();
painter.drawPixmap(QPointF(1,1),buffer,buffer.rect());
painter.restore();
painter.setPen(Qt::white);
QFont font(font());
font.setPointSize(24);
painter.setFont(font);
QFontMetrics fm(painter.font());
int fontHeigh = fm.height();
QString tmp;
tmp.sprintf("%.0f %.0f",mouseMovePos.x(),mouseMovePos.y());
//painter.drawText(0,fontHeigh,tr("%1,%2").arg(mouseMovePos.x()).arg(mouseMovePos.y()));
painter.drawText(0,fontHeigh,tmp);
tmp.clear();
tmp.sprintf("My Pos %d %d",myX,myZ);
painter.drawText(0,fontHeigh*2,tmp);
To copy to clipboard, switch view to plain text mode
result image
Bookmarks