本文整理汇总了C++中TRasterP::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterP::unlock方法的具体用法?C++ TRasterP::unlock怎么用?C++ TRasterP::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRasterP
的用法示例。
在下文中一共展示了TRasterP::unlock方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: over
void TRop::over(const TRasterP &out, const TRasterP &dn, const TRasterP &up, const TRasterGR8P &mask)
{
out->lock();
up->lock();
dn->lock();
TRaster32P out32 = out;
TRaster32P dn32 = dn;
TRaster32P up32 = up;
if (out32 && dn32 && up32)
do_over<TPixel32, TPixel32, TPixel32>(out32, dn32, up32, mask);
else {
TRaster64P out64 = out;
TRaster64P dn64 = dn;
TRaster64P up64 = up;
if (out64 && dn64 && up64)
do_over<TPixel64, TPixel64, TPixel64>(out64, dn64, up64, mask);
else
throw TRopException("unsupported pixel type");
}
out->unlock();
up->unlock();
dn->unlock();
}
示例2: gammaCorrect
void TRop::gammaCorrect(TRasterP raster, double gamma) {
if (gamma <= 0) gamma = 0.01;
raster->lock();
if ((TRaster32P)raster)
doGammaCorrect<TPixel32, UCHAR>(raster, gamma);
else if ((TRaster64P)raster)
doGammaCorrect<TPixel64, USHORT>(raster, gamma);
else {
raster->unlock();
throw TRopException("isOpaque: unsupported pixel type");
}
raster->unlock();
}
示例3: processColors
//this one incorporate the preprocessColors and the finalize function; used for swatch.(tipically on very small rasters)
TRasterP TCleanupper::processColors(const TRasterP &rin)
{
if (m_parameters->m_lineProcessingMode == lpNone)
return rin;
TRasterCM32P rcm = TRasterCM32P(rin->getSize());
if (!rcm) {
assert(!"failed finalRas allocation!");
return TRasterCM32P();
}
// Copy current cleanup palette to parameters' colors
m_parameters->m_colors.update(m_parameters->m_cleanupPalette.getPointer(), m_parameters->m_noAntialias);
bool toGr8 = (m_parameters->m_lineProcessingMode == lpGrey);
if (toGr8) {
//No (color) processing. Not even thresholding. This just means that all the important
//stuff here is made in the brightness/contrast stage...
//NOTE: Most of the color processing should be DISABLED in this case!!
//finalRas->clear();
rin->lock();
rcm->lock();
if (TRasterGR8P(rin)) {
UCHAR *rowin = rin->getRawData();
TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
for (int i = 0; i < rin->getLy(); i++) {
for (int j = 0; j < rin->getLx(); j++)
*rowout++ = *rowin++; //Direct copy for now... :(
rowin += rin->getWrap() - rin->getLx();
rowout += rcm->getWrap() - rcm->getLx();
}
} else {
TPixel32 *rowin = reinterpret_cast<TPixel32 *>(rin->getRawData());
TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
for (int i = 0; i < rin->getLy(); i++) {
for (int j = 0; j < rin->getLx(); j++)
*rowout++ = TPixelGR8::from(*rowin++).value;
rowin += rin->getWrap() - rin->getLx();
rowout += rcm->getWrap() - rcm->getLx();
}
}
rin->unlock();
rcm->unlock();
} else {
assert(TRaster32P(rin));
preprocessColors(rcm, rin, m_parameters->m_colors);
}
//outImg->setDpi(outDpi.x, outDpi.y);
CleanupPreprocessedImage cpi(m_parameters, TToonzImageP(rcm, rcm->getBounds()), toGr8);
cpi.m_autocentered = true;
TRaster32P rout = TRaster32P(rin->getSize());
finalize(rout, &cpi);
return rout;
}
示例4: makeStereoRaster
void TRop::makeStereoRaster(const TRasterP &left, const TRasterP &right) {
assert(left->getSize() == right->getSize());
left->lock();
if ((TRaster32P)left && (TRaster32P)right)
doMakeStereoRaster<TPixel32>(left, right);
else if ((TRaster64P)left && (TRaster64P)right)
doMakeStereoRaster<TPixel64>(left, right);
else {
left->unlock();
throw TRopException("setChannel: unsupported pixel type");
}
left->unlock();
}
示例5: despeckle
void TRop::despeckle(const TRasterP &ras, int sizeThreshold, bool check,
bool transparentIsWhite) {
ras->lock();
if (TRasterCM32P(ras)) {
doDespeckleCM32(ras, sizeThreshold, check);
return;
}
if (TRaster32P(ras)) {
doDespeckleRGBM<TPixel32, UCHAR>(ras, sizeThreshold, transparentIsWhite);
return;
}
if (TRaster64P(ras)) {
doDespeckleRGBM<TPixel64, USHORT>(ras, sizeThreshold, transparentIsWhite);
return;
}
if (TRasterGR8P(ras)) {
doDespeckleGR<TPixelGR8, UCHAR>(ras, sizeThreshold);
return;
}
if (TRasterGR16P(ras)) {
doDespeckleGR<TPixelGR16, USHORT>(ras, sizeThreshold);
return;
}
ras->unlock();
}
示例6: setChannel
void TRop::setChannel(const TRasterP &rin, TRasterP rout, UCHAR chan,
bool greytones) {
assert(rin->getSize() == rout->getSize());
rout->lock();
if ((TRaster32P)rin && (TRaster32P)rout)
doSetChannel<TPixel32>(rin, rout, chan, greytones);
else if ((TRaster64P)rin && (TRaster64P)rout)
doSetChannel<TPixel64>(rin, rout, chan, greytones);
else {
rout->unlock();
throw TRopException("setChannel: unsupported pixel type");
}
rout->unlock();
}
示例7: gammaCorrectRGBM
void TRop::gammaCorrectRGBM(TRasterP raster, double gammar, double gammag,
double gammab, double gammam) {
if (gammar <= 0) gammar = 0.01;
if (gammag <= 0) gammag = 0.01;
if (gammab <= 0) gammab = 0.01;
if (gammam <= 0) gammam = 0.01;
raster->lock();
if ((TRaster32P)raster)
doGammaCorrectRGBM<TPixel32, UCHAR>(raster, gammar, gammag, gammab, gammam);
else if ((TRaster64P)raster)
doGammaCorrectRGBM<TPixel64, USHORT>(raster, gammar, gammag, gammab,
gammam);
else {
raster->unlock();
throw TRopException("isOpaque: unsupported pixel type");
}
raster->unlock();
}
示例8: tglBuildMipmaps
void tglBuildMipmaps(std::vector<TRaster32P> &rasters,
const TFilePath &filepath)
{
assert(rasters.size() > 0);
TRop::ResampleFilterType resampleFilter = TRop::ClosestPixel;
TRasterP ras;
TImageReader::load(filepath, ras);
int rasLx = ras->getLx();
int rasLy = ras->getLy();
int lx = 1;
while (lx < rasLx)
lx <<= 1;
int ly = 1;
while (ly < rasLy)
ly <<= 1;
TRaster32P ras2(lx, ly);
double sx = (double)lx / (double)ras->getLx();
double sy = (double)ly / (double)ras->getLy();
#ifndef SCALE_BY_GLU
TRop::resample(ras2, ras, TScale(sx, sy), resampleFilter);
#else
ras->lock();
gluScaleImage(GL_RGBA, ras->getLx(), ras->getLy(), GL_UNSIGNED_BYTE, ras->getRawData(),
lx, ly, GL_UNSIGNED_BYTE, ras2->getRawData());
ras->unlock();
#endif
rasters[0] = ras2;
int ras2Lx = ras2->getLx();
int ras2Ly = ras2->getLy();
for (int i = 1; i < (int)rasters.size(); ++i) {
lx >>= 1;
ly >>= 1;
if (lx < 1)
lx = 1;
if (ly < 1)
ly = 1;
rasters[i] = TRaster32P(lx, ly);
sx = (double)lx / (double)ras2Lx;
sy = (double)ly / (double)ras2Ly;
rasters[i] = TRaster32P(lx, ly);
#ifndef SCALE_BY_GLU
TRop::resample(rasters[i], ras2, TScale(sx, sy), resampleFilter);
#else
ras2->lock();
gluScaleImage(GL_RGBA, ras->getLx(), ras->getLy(), GL_UNSIGNED_BYTE, ras2->getRawData(),
lx, ly, GL_UNSIGNED_BYTE, rasters[i]->getRawData());
ras2->unlock();
#endif
}
}
示例9: erodilate
void TRop::erodilate(const TRasterP &src, const TRasterP &dst,
double radius, ErodilateMaskType type)
{
assert(src->getSize() == dst->getSize());
src->lock(), dst->lock();
if ((TRaster32P)src && (TRaster32P)dst)
switch (type) {
case ED_rectangular:
::rect_erodilate<TPixel32>(src, dst, radius);
break;
case ED_circular:
::circular_erodilate<TPixel32>(src, dst, radius);
break;
default:
assert(!"Unknown mask type");
break;
}
else if ((TRaster64P)src && (TRaster64P)dst)
switch (type) {
case ED_rectangular:
::rect_erodilate<TPixel64>(src, dst, radius);
break;
case ED_circular:
::circular_erodilate<TPixel64>(src, dst, radius);
break;
default:
assert(!"Unknown mask type");
break;
}
else
assert(!"Unsupported raster type!");
src->unlock(), dst->unlock();
}
示例10: eraseRect
TRect TRasterImageUtils::eraseRect(const TRasterImageP &ri, const TRectD &area)
{
TRasterP ras = ri->getRaster();
TRect rect = convertWorldToRaster(area, ri) * ras->getBounds();
if (rect.isEmpty())
return rect;
ras->lock();
TRasterP workRas = ras->extract(rect);
if (workRas->getPixelSize() == 4)
workRas->clear();
else {
TRasterGR8P rasGR8(workRas);
if (rasGR8)
rasGR8->fill(TPixelGR8::White);
}
ras->unlock();
return rect;
}
示例11: save
void TImageWriter::save(const TImageP &img)
{
const std::string &type = toLower(m_path.getType());
Tiio::Writer *writer = Tiio::makeWriter(type);
if (!writer)
throw TImageException(m_path, "unsupported format for raster images");
writer->setProperties(m_properties);
FILE *file = fopen(m_path, "wb");
if (file == NULL)
throw TImageException(m_path, "Can't write file");
if (TRasterImageP ri = img) {
TImageInfo info;
TRasterP ras;
TRasterGR8P rasGr = ri->getRaster();
TRaster32P ras32 = ri->getRaster();
TRaster64P ras64 = ri->getRaster();
TEnumProperty *p = m_properties ? (TEnumProperty *)m_properties->getProperty("Bits Per Pixel")
: 0;
if (p && ri->isScanBW()) {
const std::vector<std::wstring> &range = p->getRange();
p->setValue(range[2]); // Horrible. See tiio_tif.cpp (732 or near) -.-'
}
int bpp = p ? atoi((toString(p->getValue()).c_str())) : 32;
// bpp 1 8 16 24 32 40 48 56 64
int spp[] = {1, 1, 1, 4, 4, 0, 4, 0, 4}; // 0s are for pixel sizes which are normally unsupported
int bps[] = {1, 8, 16, 8, 8, 0, 16, 0, 16}; // by image formats, let alone by Toonz raster ones.
// The 24 and 48 cases get automatically promoted to 32 and 64.
int bypp = bpp / 8;
assert(bypp < boost::size(spp) && spp[bypp] && bps[bypp]);
info.m_samplePerPixel = spp[bypp];
info.m_bitsPerSample = bps[bypp];
if (rasGr) {
if (bypp < 2) // Seems 16 bit greymaps are not handled... why?
ras = rasGr; // we do have a Toonz raster for those... >:|
else
convertForWriting(ras, rasGr, bpp);
} else if (ras32) {
if (bpp == 32 || bpp == 24)
ras = ras32;
else
convertForWriting(ras, ras32, bpp);
} else if (ras64) {
if (bpp == 64 || bpp == 48)
ras = ras64;
else
convertForWriting(ras, ras64, bpp);
} else {
fclose(file);
throw TImageException(m_path, "unsupported raster type");
}
info.m_lx = ras->getLx();
info.m_ly = ras->getLy();
ri->getDpi(info.m_dpix, info.m_dpiy);
if (writer->getProperties() && m_properties)
writer->getProperties()->setProperties(m_properties);
writer->open(file, info);
ras->lock();
if (writer->getRowOrder() == Tiio::BOTTOM2TOP) {
if (bpp == 1 || bpp == 8 || bpp == 24 || bpp == 32 || bpp == 16)
for (int i = 0; i < ras->getLy(); i++)
writer->writeLine((char *)ras->getRawData(0, i));
else
for (int i = 0; i < ras->getLy(); i++)
writer->writeLine((short *)ras->getRawData(0, i));
} else {
if (bpp == 1 || bpp == 8 || bpp == 24 || bpp == 32 || bpp == 16)
for (int i = ras->getLy() - 1; i >= 0; i--)
writer->writeLine((char *)ras->getRawData(0, i));
else
for (int i = ras->getLy() - 1; i >= 0; i--)
writer->writeLine((short *)ras->getRawData(0, i));
}
ras->unlock();
writer->flush();
delete writer;
} else if (TVectorImageP vi = img) {
Tiio::VectorWriter *writer = Tiio::makeVectorWriter(type);
if (!writer) {
fclose(file);
throw TImageException(m_path, "unsupported format for vector images");
}
//.........这里部分代码省略.........
示例12: tessellate
void TglTessellator::tessellate(const TColorFunction *cf, const bool antiAliasing, TRegionOutline &outline, TRaster32P texture)
{
//QMutexLocker sl(m_mutex);
checkErrorsByGL;
glEnable(GL_TEXTURE_2D);
glColor4d(1, 1, 1, 1);
checkErrorsByGL;
TextureInfoForGL texInfo;
int pow2Lx = tcg::numeric_ops::GE_2Power((unsigned int)texture->getLx());
int pow2Ly = tcg::numeric_ops::GE_2Power((unsigned int)texture->getLy());
TAffine aff;
if (texture->getLx() != pow2Lx || texture->getLy() != pow2Ly) {
TRaster32P r(pow2Lx, pow2Ly);
aff = TScale((double)pow2Lx / texture->getLx(), (double)pow2Ly / texture->getLy());
TRop::resample(r, texture, aff.place(texture->getCenterD(), r->getCenterD()));
texture = r;
glPushMatrix();
tglMultMatrix(aff.inv());
}
// If GL_BRGA isn't present make a proper texture to use (... obsolete?)
texture->lock();
TRasterP texImage = prepareTexture(texture, texInfo);
checkErrorsByGL;
if (texImage != texture)
texImage->lock();
assert(texImage->getLx() == texImage->getWrap());
GLuint texId;
glGenTextures(1, &texId); // Generate a texture name
checkErrorsByGL;
glBindTexture(GL_TEXTURE_2D, texId); // Bind it 'active'
checkErrorsByGL;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // These must be invoked
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // on a bound texture
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //
checkErrorsByGL;
glTexEnvf(GL_TEXTURE_ENV, // This too ?
GL_TEXTURE_ENV_MODE, // Better here anyway
GL_MODULATE); //
checkErrorsByGL;
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
checkErrorsByGL;
glTexImage2D(GL_TEXTURE_2D,
0, // one level only
texInfo.internalformat, // pixel channels count
texInfo.width, // width
texInfo.height, // height
0, // border size
texInfo.type, // pixel format // crappy names
texInfo.format, // pixel data type // oh, SO much
texImage->getRawData());
checkErrorsByGL;
texture->unlock();
if (texImage != texture)
texImage->unlock();
TglTessellator::GLTess glTess;
gluTessCallback(glTess.m_tess, GLU_TESS_VERTEX, (GluCallback)tessellateTexture);
checkErrorsByGL;
//------------------------//
if (aff != TAffine())
doTessellate(glTess, cf, antiAliasing, outline, aff); // Tessellate & render
else
doTessellate(glTess, cf, antiAliasing, outline); // Tessellate & render
checkErrorsByGL;
//------------------------//
if (aff != TAffine())
glPopMatrix();
glDeleteTextures(1, &texId); // Delete & unbind texture
checkErrorsByGL;
glDisable(GL_TEXTURE_2D);
checkErrorsByGL;
}