조회 수 6551 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

임의 메로리 영역(QImage)에 QPainter를 이용하여 그리고 파일로 저장하는 방법을 보여준다.

#include <QApplication>
#include <QImage>
#include <QPainter>

#define WIDTH (1024)
#define HEIGHT (768)

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);


    unsigned char *buffer = nullptr;
    QImage *canvas = nullptr;

    buffer = new unsigned char[WIDTH * HEIGHT * 4];
    canvas = new QImage(buffer, WIDTH, HEIGHT, QImage::Format_ARGB32_Premultiplied);
    canvas->fill(0xffffffff);

    QRectF rectangle(0, 0, 1024, 768);
    int startAngle = 30 * 16;
    int spanAngle = 120 * 16;

    QPainter painter(canvas);
    painter.drawPie(rectangle, startAngle, spanAngle);

    canvas->save("test.png", "PNG");

    delete [] buffer;
    painter.end();
    delete canvas;

    return a.exec();
}

 

위 예제 소스코드는 아래 그림의 결과물을 만들어 낸다.

 

 

test.png

 

TAG •

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 QML and Qt Quick Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서 운영자 2019.01.05 110090
20 Installation and Deployment Windows환경에서 mingw로 Qt 5.10 정적(static)빌드 file makersweb 2018.02.01 8261
19 General and Desktop 다국어 지원 어플리케이션 개발 file makersweb 2018.01.27 5453
18 General and Desktop Qt 어플리에이션 전역에 폰트 설정 makersweb 2018.01.24 8508
17 Installation and Deployment Qt 3D Studio 시작하기 file makersweb 2018.01.11 6265
16 Mobile and Embedded QPA 플러그인과 HTML5 Backend file makersweb 2017.12.27 3709
» General and Desktop 임의의 메모리 영역(QImage)에 QPainter를 이용하여 그리기 file makersweb 2017.12.19 6551
14 QML and Qt Quick QML에서 undefined를 확인하는 방법 makersweb 2017.11.29 4374
13 Mobile and Embedded QPA 플러그인과 EGLFS file makersweb 2017.11.21 7325
12 General and Desktop 타임스탬프( timestamp) 유닉스 시간 makersweb 2017.10.19 4692
11 General and Desktop Qt Logging Rule, Qt 프레임워크 로그 출력 makersweb 2017.01.13 7331
10 QString 문자열에서 숫자만 추출해서 QString으로 반환 makersweb 2017.01.10 6060
9 General and Desktop 멀티 스레드환경, 스레드에 안전한 이벤트처리 makersweb 2016.10.27 7713
8 Installation and Deployment Ubuntu Linux에서 Qt Creator 설치 file makersweb 2016.03.06 13849
7 QtConcurrent를 이용하여 쓰레드를 만드는 방법과 MapReduce file makersweb 2016.01.24 12263
6 General and Desktop Qt 프로그래밍의 시작 makersweb 2015.10.25 17917
5 General and Desktop Qt의 스레드간 시그널 슬롯의 커넥션타입 1 makersweb 2015.10.24 13766
4 General and Desktop Qt의 시그널 슬롯 시스템 file makersweb 2015.10.20 27670
3 C++ Class QQuickImageProvider 를 이용한 Qml 에서 이미지 표시 makersweb 2015.10.18 8567
2 QML and Qt Quick Qml 사용자 ScrollBar 구현 file makersweb 2015.07.24 8688
1 QML and Qt Quick z-order 를 컨트롤 하기위한 방법 makersweb 2015.05.13 9656
Board Pagination Prev 1 ... 5 6 7 8 9 Next
/ 9