QDicomUtility
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// Created by 87714 on 2021/7/26.
|
||||
//
|
||||
|
||||
#ifndef OMEGAV_QDICOMUITILITY_H
|
||||
#define OMEGAV_QDICOMUITILITY_H
|
||||
#ifndef OMEGAV_QDICOMUTILITY_H
|
||||
#define OMEGAV_QDICOMUTILITY_H
|
||||
|
||||
|
||||
#include <QtGui/qpixmap.h>
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <dcmtk/dcmdata/dcfilefo.h>
|
||||
#include <dcmtk/dcmimgle/dcmimage.h>
|
||||
|
||||
QPixmap GetImageFormDcmFile(const QString& filepath, int wl, int ww)
|
||||
QPixmap GetImageFormDcmFile(const QString& filepath, int wl, int ww, unsigned short sample)
|
||||
{
|
||||
DcmRLEDecoderRegistration::registerCodecs(OFFalse, OFTrue);//注册解码器
|
||||
/// register JPEG decompression codecs
|
||||
@@ -35,12 +35,22 @@ QPixmap GetImageFormDcmFile(const QString& filepath, int wl, int ww)
|
||||
bool flag = dcmImage.getWidth() > dcmImage.getHeight();
|
||||
DicomImage* sdcmImage = dcmImage.createScaledImage(w,0,0,1);
|
||||
sdcmImage->setWindow(wl, ww);
|
||||
if (sample==1){
|
||||
uchar* data = (uchar*)sdcmImage->getOutputData(8);//按8位的位宽取数据
|
||||
unsigned long size = sdcmImage->getOutputDataSize(8);
|
||||
QImage image(data, sdcmImage->getWidth(), sdcmImage->getHeight(), QImage::Format_Grayscale8);//使用8位深度的灰度图做输出
|
||||
if (sdcmImage->getHeight() > 100) image = image.scaledToHeight(100);
|
||||
QPainter p(&pixmap);
|
||||
p.drawPixmap(50 - image.width()/2, 50-image.height()/2, QPixmap::fromImage(image));
|
||||
}
|
||||
//RGB color image
|
||||
else{
|
||||
uchar* data = (uchar*)sdcmImage->getOutputData(8);//按8位的位宽取数据
|
||||
QImage image(data, sdcmImage->getWidth(), sdcmImage->getHeight(), QImage::Format_RGB888);//使用8位深度的灰度图做输出
|
||||
if (sdcmImage->getHeight() > 100) image = image.scaledToHeight(100);
|
||||
QPainter p(&pixmap);
|
||||
p.drawPixmap(50 - image.width()/2, 50-image.height()/2, QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
|
||||
// p.save();
|
||||
}
|
||||
@@ -53,4 +63,4 @@ QPixmap GetImageFormDcmFile(const QString& filepath, int wl, int ww)
|
||||
}
|
||||
|
||||
|
||||
#endif //OMEGAV_QDICOMUITILITY_H
|
||||
#endif //OMEGAV_QDICOMUTILITY_H
|
||||
Reference in New Issue
Block a user