本文整理汇总了C++中pixelType函数的典型用法代码示例。如果您正苦于以下问题:C++ pixelType函数的具体用法?C++ pixelType怎么用?C++ pixelType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixelType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromFile
bool QGLPixmapData::fromFile(const QString &filename, const char *format,
Qt::ImageConversionFlags flags)
{
if (pixelType() == QPixmapData::BitmapType)
return QPixmapData::fromFile(filename, format, flags);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return false;
QByteArray data = file.peek(64);
bool alpha;
if (m_texture.canBindCompressedTexture
(data.constData(), data.size(), format, &alpha)) {
resize(0, 0);
data = file.readAll();
file.close();
QGLShareContextScope ctx(qt_gl_share_widget()->context());
QSize size = m_texture.bindCompressedTexture
(data.constData(), data.size(), format);
if (!size.isEmpty()) {
w = size.width();
h = size.height();
is_null = false;
d = 32;
m_hasAlpha = alpha;
m_source = QImage();
m_dirty = isValid();
return true;
}
return false;
}
fromImage(QImageReader(&file, format).read(), flags);
return !isNull();
}
示例2: pixelType
void QGLPixmapData::resize(int width, int height)
{
if (width == w && height == h)
return;
if (width <= 0 || height <= 0) {
width = 0;
height = 0;
}
w = width;
h = height;
is_null = (w <= 0 || h <= 0);
d = pixelType() == QPixmapData::PixmapType ? 32 : 1;
if (m_texture.id) {
QGLShareContextScope ctx(qt_gl_share_context());
glDeleteTextures(1, &m_texture.id);
m_texture.id = 0;
}
m_source = QImage();
m_dirty = isValid();
setSerialNumber(++qt_gl_pixmap_serial);
}
示例3: setSerialNumber
void QMacPixmapData::resize(int width, int height)
{
setSerialNumber(++qt_pixmap_serial);
w = width;
h = height;
is_null = (w <= 0 || h <= 0);
d = (pixelType() == BitmapType ? 1 : 32);
bool make_null = w <= 0 || h <= 0; // create null pixmap
if (make_null || d == 0) {
w = 0;
h = 0;
is_null = true;
d = 0;
if (!make_null)
qWarning("Qt: QPixmap: Invalid pixmap parameters");
return;
}
if (w < 1 || h < 1)
return;
//create the pixels
bytesPerRow = w * sizeof(quint32); // Minimum bytes per row.
// Quartz2D likes things as a multple of 16 (for now).
bytesPerRow = COMPTUE_BEST_BYTES_PER_ROW(bytesPerRow);
macCreatePixels();
}
示例4: TRACE
void QEglGLPixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
{
TRACE();
resize(image.width(), image.height());
if (pixelType() == BitmapType) {
m_source = image.convertToFormat(QImage::Format_MonoLSB);
} else {
QImage::Format format = QImage::Format_RGB32;
if (qApp->desktop()->depth() == 16)
format = QImage::Format_RGB16;
if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels())
format = QImage::Format_ARGB32_Premultiplied;;
m_source = image.convertToFormat(format);
}
m_dirty = true;
m_hasFillColor = false;
m_hasAlpha = m_source.hasAlphaChannel();
w = image.width();
h = image.height();
is_null = (w <= 0 || h <= 0);
d = m_source.depth();
if (m_texture.id) {
QGLShareContextScope ctx(qt_gl_share_widget()->context());
glDeleteTextures(1, &m_texture.id);
m_texture.id = 0;
}
}
示例5: defined
void QGLPixmapData::fromNativeType(void* pixmap, NativeType type)
{
if (type == QPixmapData::SgImage && pixmap) {
#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
m_sgImage = new RSgImage;
m_sgImage->Open(sgImage->Id());
TSgImageInfo info;
sgImage->GetInfo(info);
w = info.iSizeInPixels.iWidth;
h = info.iSizeInPixels.iHeight;
d = symbianPixeFormatBitsPerPixel((TUidPixelFormat)info.iPixelFormat);
m_source = QVolatileImage();
m_hasAlpha = true;
m_hasFillColor = false;
m_dirty = true;
is_null = (w <= 0 || h <= 0);
#endif
} else if (type == QPixmapData::FbsBitmap && pixmap) {
CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap);
QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
if (size.width() == w && size.height() == h)
setSerialNumber(++qt_gl_pixmap_serial);
resize(size.width(), size.height());
m_source = QVolatileImage(bitmap);
if (pixelType() == BitmapType) {
m_source.ensureFormat(QImage::Format_MonoLSB);
} else if (!knownGoodFormat(m_source.format())) {
m_source.beginDataAccess();
QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor);
m_source.endDataAccess(true);
m_source.ensureFormat(format);
}
m_hasAlpha = m_source.hasAlphaChannel();
m_hasFillColor = false;
m_dirty = true;
d = m_source.depth();
} else if (type == QPixmapData::VolatileImage && pixmap) {
// Support QS60Style in more efficient skin graphics retrieval.
QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
if (img->width() == w && img->height() == h)
setSerialNumber(++qt_gl_pixmap_serial);
resize(img->width(), img->height());
m_source = *img;
m_hasAlpha = m_source.hasAlphaChannel();
m_hasFillColor = false;
m_dirty = true;
d = m_source.depth();
} else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
destroyTexture();
nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap);
// Cannot defer the retrieval, we need at least the size right away.
createFromNativeImageHandleProvider();
}
}
示例6: CubeIoHandler
/**
* Construct a tile handler. This will determine a good chunk size to put
* into the output cube.
*
* @param dataFile The file with cube DN data in it
* @param virtualBandList The mapping from virtual band to physical band, see
* CubeIoHandler's description.
* @param labels The Pvl labels for the cube
* @param alreadyOnDisk True if the cube is allocated on the disk, false
* otherwise
*/
CubeTileHandler::CubeTileHandler(QFile * dataFile,
const QList<int> *virtualBandList, const Pvl &labels, bool alreadyOnDisk)
: CubeIoHandler(dataFile, virtualBandList, labels, alreadyOnDisk) {
const PvlObject &core = labels.findObject("IsisCube").findObject("Core");
if(core.hasKeyword("Format")) {
setChunkSizes(core["TileSamples"], core["TileLines"], 1);
}
else {
// up to 1MB chunks
int sampleChunkSize =
findGoodSize(512 * 4 / SizeOf(pixelType()), sampleCount());
int lineChunkSize =
findGoodSize(512 * 4 / SizeOf(pixelType()), lineCount());
setChunkSizes(sampleChunkSize, lineChunkSize, 1);
}
}
示例7: QImage
void QRasterPlatformPixmap::resize(int width, int height)
{
QImage::Format format;
if (pixelType() == BitmapType)
format = QImage::Format_MonoLSB;
else
format = QNativeImage::systemFormat();
image = QImage(width, height, format);
w = width;
h = height;
d = image.depth();
is_null = (w <= 0 || h <= 0);
if (pixelType() == BitmapType && !image.isNull()) {
image.setColorCount(2);
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
}
setSerialNumber(image.cacheKey() >> 32);
}
示例8: QDirectFBPixmapData
QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
Qt::TransformationMode mode) const
{
if (!surface || transform.type() != QTransform::TxScale
|| mode != Qt::FastTransformation)
{
QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
const QImage *image = that->buffer();
if (image) { // avoid deep copy
const QImage transformed = image->transformed(transform, mode);
that->unlockDirectFB();
QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
data->fromImage(transformed, Qt::AutoColor);
return QPixmap(data);
}
return QPixmapData::transformed(transform, mode);
}
int w, h;
surface->GetSize(surface, &w, &h);
const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
if (size.isEmpty())
return QPixmap();
QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
data->resize(size.width(), size.height());
IDirectFBSurface *dest = data->surface;
dest->SetBlittingFlags(dest, DSBLIT_NOFX);
const DFBRectangle srcRect = { 0, 0, w, h };
const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
dest->StretchBlit(dest, surface, &srcRect, &destRect);
return QPixmap(data);
}
示例9: conversion
/*!
out-of-place conversion (inPlace == false) will always detach()
*/
void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
{
if (image.size() == QSize(w, h))
setSerialNumber(++qt_gl_pixmap_serial);
resize(image.width(), image.height());
if (pixelType() == BitmapType) {
m_source = image.convertToFormat(QImage::Format_MonoLSB);
} else {
QImage::Format format = QImage::Format_RGB32;
if (qApp->desktop()->depth() == 16)
format = QImage::Format_RGB16;
if (image.hasAlphaChannel()
&& ((flags & Qt::NoOpaqueDetection)
|| const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
format = QImage::Format_ARGB32_Premultiplied;;
if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
m_source = image;
} else {
m_source = image.convertToFormat(format);
// convertToFormat won't detach the image if format stays the same.
if (image.format() == format)
m_source.detach();
}
}
m_dirty = true;
m_hasFillColor = false;
m_hasAlpha = m_source.hasAlphaChannel();
w = image.width();
h = image.height();
is_null = (w <= 0 || h <= 0);
d = m_source.depth();
if (m_texture.id) {
QGLShareContextScope ctx(qt_gl_share_context());
glDeleteTextures(1, &m_texture.id);
m_texture.id = 0;
}
}
示例10: pixelType
mitk::DataNode::Pointer mitk::Tool::CreateEmptySegmentationNode( Image* original, const std::string& organName, const mitk::Color& color )
{
// we NEED a reference image for size etc.
if (!original) return NULL;
// actually create a new empty segmentation
PixelType pixelType(mitk::MakeScalarPixelType<DefaultSegmentationDataType>() );
Image::Pointer segmentation = Image::New();
if (original->GetDimension() == 2)
{
const unsigned int dimensions[] = { original->GetDimension(0), original->GetDimension(1), 1 };
segmentation->Initialize(pixelType, 3, dimensions);
}
else
{
segmentation->Initialize(pixelType, original->GetDimension(), original->GetDimensions());
}
unsigned int byteSize = sizeof(DefaultSegmentationDataType);
for (unsigned int dim = 0; dim < segmentation->GetDimension(); ++dim)
{
byteSize *= segmentation->GetDimension(dim);
}
memset( segmentation->GetData(), 0, byteSize );
if (original->GetTimeSlicedGeometry() )
{
AffineGeometryFrame3D::Pointer originalGeometryAGF = original->GetTimeSlicedGeometry()->Clone();
TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() );
segmentation->SetGeometry( originalGeometry );
}
else
{
Tool::ErrorMessage("Original image does not have a 'Time sliced geometry'! Cannot create a segmentation.");
return NULL;
}
return CreateSegmentationNode( segmentation, organName, color );
}
示例11: CastToItkImage
void mitk::CorrectorAlgorithm::ItkCalculateDifferenceImage( itk::Image<TPixel, VImageDimension>* originalImage, Image* modifiedMITKImage )
{
typedef itk::Image<ipMITKSegmentationTYPE, VImageDimension> ModifiedImageType;
typedef itk::Image<short signed int, VImageDimension> DiffImageType;
typedef itk::ImageRegionConstIterator< itk::Image<TPixel,VImageDimension> > OriginalSliceIteratorType;
typedef itk::ImageRegionConstIterator< ModifiedImageType > ModifiedSliceIteratorType;
typedef itk::ImageRegionIterator< DiffImageType > DiffSliceIteratorType;
typename ModifiedImageType::Pointer modifiedImage;
CastToItkImage( modifiedMITKImage, modifiedImage );
// create new image as a copy of the input
// this new image is the output of this filter class
typename DiffImageType::Pointer diffImage;
m_DifferenceImage = Image::New();
PixelType pixelType( typeid(short signed int) );
m_DifferenceImage->Initialize( pixelType, 2, modifiedMITKImage->GetDimensions() );
CastToItkImage( m_DifferenceImage, diffImage );
// iterators over both input images (original and modified) and the output image (diff)
ModifiedSliceIteratorType modifiedIterator( modifiedImage, diffImage->GetLargestPossibleRegion() );
OriginalSliceIteratorType originalIterator( originalImage, diffImage->GetLargestPossibleRegion() );
DiffSliceIteratorType diffIterator( diffImage, diffImage->GetLargestPossibleRegion() );
modifiedIterator.GoToBegin();
originalIterator.GoToBegin();
diffIterator.GoToBegin();
while ( !diffIterator.IsAtEnd() )
{
short signed int difference = static_cast<short signed int>( static_cast<signed int>(modifiedIterator.Get()) -
static_cast<signed int>(originalIterator.Get())); // not good for bigger values ?!
diffIterator.Set( difference );
++modifiedIterator;
++originalIterator;
++diffIterator;
}
}
示例12: fillImage
QImage QGLPixmapData::fillImage(const QColor &color) const
{
QImage img;
if (pixelType() == BitmapType) {
img = QImage(w, h, QImage::Format_MonoLSB);
img.setColorCount(2);
img.setColor(0, QColor(Qt::color0).rgba());
img.setColor(1, QColor(Qt::color1).rgba());
if (color == Qt::color1)
img.fill(1);
else
img.fill(0);
} else {
img = QImage(w, h,
m_hasAlpha
? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGB32);
img.fill(PREMUL(color.rgba()));
}
return img;
}
示例13: switch
void mitk::OverwriteSliceImageFilter::GenerateData()
{
//
// this is the place to implement the major part of undo functionality (bug #491)
// here we have to create undo/do operations
//
// WHO is the operation actor? This object may not be destroyed ever (design of undo stack)!
// -> some singleton method of this filter?
//
// neccessary additional objects:
// - something that executes the operations
// - the operation class (must hold a binary diff or something)
// - observer commands to know when the image is deleted (no further action then, perhaps even remove the operations from the undo stack)
//
Image::ConstPointer input = ImageToImageFilter::GetInput(0);
Image::ConstPointer input3D = input;
Image::ConstPointer slice = m_SliceImage;
if ( input.IsNull() || slice.IsNull() ) return;
switch (m_SliceDimension)
{
default:
case 2:
m_Dimension0 = 0;
m_Dimension1 = 1;
break;
case 1:
m_Dimension0 = 0;
m_Dimension1 = 2;
break;
case 0:
m_Dimension0 = 1;
m_Dimension1 = 2;
break;
}
if ( slice->GetDimension() < 2 || input->GetDimension() > 4 ||
slice->GetDimension(0) != input->GetDimension(m_Dimension0) ||
slice->GetDimension(1) != input->GetDimension(m_Dimension1) ||
m_SliceIndex >= input->GetDimension(m_SliceDimension)
)
{
itkExceptionMacro("Slice and image dimensions differ or slice index is too large. Sorry, cannot work like this.");
return;
}
if ( input->GetDimension() == 4 )
{
ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New();
timeSelector->SetInput( input );
timeSelector->SetTimeNr( m_TimeStep );
timeSelector->UpdateLargestPossibleRegion();
input3D = timeSelector->GetOutput();
}
if ( m_SliceDifferenceImage.IsNull() ||
m_SliceDifferenceImage->GetDimension(0) != m_SliceImage->GetDimension(0) ||
m_SliceDifferenceImage->GetDimension(1) != m_SliceImage->GetDimension(1) )
{
m_SliceDifferenceImage = mitk::Image::New();
mitk::PixelType pixelType( mitk::MakeScalarPixelType<short signed int>() );
m_SliceDifferenceImage->Initialize( pixelType, 2, m_SliceImage->GetDimensions() );
}
//MITK_INFO << "Overwriting slice " << m_SliceIndex << " in dimension " << m_SliceDimension << " at time step " << m_TimeStep << std::endl;
// this will do a long long if/else to find out both pixel types
AccessFixedDimensionByItk( input3D, ItkImageSwitch, 3 );
SegmentationInterpolationController* interpolator = SegmentationInterpolationController::InterpolatorForImage( input );
if (interpolator)
{
interpolator->BlockModified(true);
interpolator->SetChangedSlice( m_SliceDifferenceImage, m_SliceDimension, m_SliceIndex, m_TimeStep );
}
if ( m_CreateUndoInformation )
{
// create do/undo operations (we don't execute the doOp here, because it has already been executed during calculation of the diff image
ApplyDiffImageOperation* doOp = new ApplyDiffImageOperation( OpTEST, const_cast<Image*>(input.GetPointer()), m_SliceDifferenceImage, m_TimeStep, m_SliceDimension, m_SliceIndex );
ApplyDiffImageOperation* undoOp = new ApplyDiffImageOperation( OpTEST, const_cast<Image*>(input.GetPointer()), m_SliceDifferenceImage, m_TimeStep, m_SliceDimension, m_SliceIndex );
undoOp->SetFactor( -1.0 );
OperationEvent* undoStackItem = new OperationEvent( DiffImageApplier::GetInstanceForUndo(), doOp, undoOp, this->EventDescription(m_SliceDimension, m_SliceIndex, m_TimeStep) );
UndoController::GetCurrentUndoModel()->SetOperationEvent( undoStackItem );
}
// this image is modified (good to know for the renderer)
input->Modified();
if (interpolator)
{
interpolator->BlockModified(false);
}
}
示例14: MUCam_setBitCount
/**
* Handles "PixelType" property.
*/
int MUCamSource::OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct)
{
if (eAct == MM::AfterSet)
{
string val;
pProp->Get(val);
if (val.compare(g_PixelType_8bit) == 0)
{
MUCam_setBitCount(hCameras_[currentCam_], 8);
bytesPerPixel_ = 1;
bitCnt_ = 8;
}
else if (val.compare(g_PixelType_16bit) == 0)
{
MUCam_setBitCount(hCameras_[currentCam_], 16);
bytesPerPixel_ = 2;
bitCnt_ = 16;
}
else if (val.compare(g_PixelType_32bitRGB) == 0)
{
MUCam_setBitCount(hCameras_[currentCam_], 8);
bytesPerPixel_ = 4;
bitCnt_ = 24;
}
else if (val.compare(g_PixelType_64bitRGB) == 0)
{
MUCam_setBitCount(hCameras_[currentCam_], 16);
bytesPerPixel_ = 8;
bitCnt_ = 48;
}
else
assert(false);
////////////////////////////////
////////////////////////////////////////////////////////////////////////
char buf[MM::MaxStrLength];
GetProperty(MM::g_Keyword_PixelType, buf);
std::string pixelType(buf);
if (pixelType.compare(g_PixelType_8bit) == 0)
{
if(bytesPerPixel_ == 2)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_16bit);
}
else if(bytesPerPixel_ == 4)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_32bitRGB);
}
else if(bytesPerPixel_ == 8)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_64bitRGB);
}
}
else if (pixelType.compare(g_PixelType_16bit) == 0)
{
if(bytesPerPixel_ == 1)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_8bit);
}
else if(bytesPerPixel_ == 4)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_32bitRGB);
}
else if(bytesPerPixel_ == 8)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_64bitRGB);
}
}
else if (pixelType.compare(g_PixelType_32bitRGB) == 0)
{
if(bytesPerPixel_ == 1)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_8bit);
}
else if(bytesPerPixel_ == 2)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_16bit);
}
else if(bytesPerPixel_ == 8)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_64bitRGB);
}
}
else if (pixelType.compare(g_PixelType_64bitRGB) == 0)
{
if(bytesPerPixel_ == 1)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_8bit);
}
else if(bytesPerPixel_ == 2)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_16bit);
}
else if(bytesPerPixel_ == 4)
{
SetProperty(MM::g_Keyword_PixelType, g_PixelType_32bitRGB);
//.........这里部分代码省略.........
示例15: QMacPixmapData
QPixmapData *QMacPixmapData::createCompatiblePixmapData() const
{
return new QMacPixmapData(pixelType());
}