本文整理汇总了C++中TRaster32P::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ TRaster32P::unlock方法的具体用法?C++ TRaster32P::unlock怎么用?C++ TRaster32P::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRaster32P
的用法示例。
在下文中一共展示了TRaster32P::unlock方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMatteAndYMirror
//------------------------------------------------
inline void setMatteAndYMirror(const TRaster32P &ras)
{
ras->lock();
TPixel32 *upRow = ras->pixels();
TPixel32 *dwRow = ras->pixels(ras->getLy() - 1);
int hLy = (int)(ras->getLy() / 2. + 0.5); //piccola pessimizzazione...
int wrap = ras->getWrap();
int lx = ras->getLx();
TPixel32 *upPix = 0;
TPixel32 *lastPix = ras->pixels(hLy);
while (upPix < lastPix) {
upPix = upRow;
TPixel32 *dwPix = dwRow;
TPixel32 *endPix = upPix + lx;
while (upPix < endPix) {
TPixel32 tmpPix(upPix->r, upPix->g, upPix->b, 0xff);
*upPix = *dwPix;
upPix->m = 0xff;
*dwPix = tmpPix;
++upPix;
++dwPix;
}
upRow += wrap;
dwRow -= wrap;
}
ras->unlock();
}
示例2: swapRBChannels
void TRop::swapRBChannels(const TRaster32P &r) {
int lx = r->getLx();
int y = r->getLy();
r->lock();
while (--y >= 0) {
TPixel32 *pix = r->pixels(y);
TPixel32 *endPix = pix + lx;
while (pix < endPix) {
tswap(pix->r, pix->b);
++pix;
}
}
r->unlock();
}
示例3:
static void addBackground32(TRaster32P ras, const TPixel32 &col)
{
ras->lock();
int nrows = ras->getLy();
while (nrows-- > 0) {
TPixel32 *pix = ras->pixels(nrows);
TPixel32 *endPix = pix + ras->getLx();
while (pix < endPix) {
*pix = overPix(col, *pix);
pix++;
}
}
ras->unlock();
}
示例4: load
TImageP TImageReaderBmp::load()
{
TImageP image;
void *buff;
int retCode = readbmp(getFilePath().getWideString().c_str(), &m_lx, &m_ly, &buff);
if (retCode != OK) {
throw TImageException(getFilePath(), buildBMPExceptionString(retCode));
}
TRaster32P raster;
raster.create(m_lx, m_ly);
raster->lock();
memcpy(raster->pixels(), buff, m_lx * m_ly * sizeof(TPixel32));
raster->unlock();
TRasterImageP rasImage(raster);
// image->setRaster(raster);
delete[] buff;
return TImageP(rasImage);
}
示例5: copyAndSwapRBChannels
TRaster32P TRop::copyAndSwapRBChannels(const TRaster32P &srcRaster) {
TRaster32P newRaster(srcRaster->getSize());
int lx = srcRaster->getLx();
int y = srcRaster->getLy();
srcRaster->lock();
newRaster->lock();
while (--y >= 0) {
TPixel32 *pix = srcRaster->pixels(y);
TPixel32 *newpix = newRaster->pixels(y);
TPixel32 *endPix = pix + lx;
while (pix < endPix) {
newpix->r = pix->b;
newpix->g = pix->g;
newpix->b = pix->r;
newpix->m = pix->m;
++pix;
++newpix;
}
}
srcRaster->unlock();
newRaster->unlock();
return newRaster;
}
示例6: brush
//.........这里部分代码省略.........
segm.x = tround(yMin / m);
segm.y = yMin;
}
int dSegm = tfloor(alpha * (segm.x + 0.5) + beta * (segm.y + 1));
while (segm.y <= yMax) {
int xMin, xMax;
if (k > 0) {
xMin = tmax(a.x + segm.x, 0); // clipping x + ritorno alle
xMax = tmin(a.x + segm.x, lx - 1); // coordinate "di schermo"
} else {
xMin = tmax(a.x - segm.x, 0); // clipping x + riflessione + ritorno
xMax = tmin(a.x - segm.x, lx - 1); // alle coordinate "di schermo"
}
TPixel32 *p = ras->pixels(segm.y + a.y) + xMin;
TPixel32 *q = p + (xMax - xMin);
while (p <= q)
*p++ = col;
if (dSegm <= 0) // NordEst
{
dSegm = dSegm + incNE;
segm.x++;
} else // Nord
{
dSegm = dSegm + incN;
}
segm.y++;
}
}
ras->unlock();
return;
}
HalfCord halfCord(radius);
int x, y;
// ----- punti iniziali coincidenti: disegna un cerchio
if (a == b) {
int yMin = tmax(a.y - radius, 0); // clipping y
int yMax = tmin(a.y + radius, ly - 1); // clipping y
for (y = yMin; y <= yMax; y++) {
int deltay = abs(y - a.y);
int xMin = tmax(a.x - halfCord.getCord(deltay), 0); // clipping x
int xMax = tmin(a.x + halfCord.getCord(deltay), lx - 1); // clipping x
TPixel32 *p = ras->pixels(y) + xMin;
TPixel32 *q = p + (xMax - xMin);
while (p <= q)
*p++ = col;
}
ras->unlock();
return;
}
// ----- rettangolo orizzontale (a.y = b.y, a.x != b.x)
if (a.y == b.y) {
int yMin = tmax((a.y - radius), 0); // clipping y
int yMax = tmin((a.y + radius), ly - 1); // clipping y
int xLeft = tmin(a.x, b.x);
int xRight = tmax(a.x, b.x);
for (y = yMin; y <= yMax; y++) {
int deltay = abs(y - a.y);
示例7: subCompute
//.........这里部分代码省略.........
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
// do OpenGL draw
double lwTex = (double)(inBBoxLx - 1) / (double)(texWidth - 1);
double lhTex = (double)(inBBoxLy - 1) / (double)(texHeight - 1);
TPointD tex00 = TPointD(0.0, 0.0);
TPointD tex10 = TPointD(lwTex, 0.0);
TPointD tex11 = TPointD(lwTex, lhTex);
TPointD tex01 = TPointD(0.0, lhTex);
GLenum polygonStyle;
if (wireframe) {
polygonStyle = GL_LINE;
glDisable(GL_TEXTURE_2D);
} else
polygonStyle = GL_FILL;
checkErrorsByGL p00.x /= ri.m_shrinkX;
p00.y /= ri.m_shrinkY;
p10.x /= ri.m_shrinkX;
p10.y /= ri.m_shrinkY;
p11.x /= ri.m_shrinkX;
p11.y /= ri.m_shrinkY;
p01.x /= ri.m_shrinkX;
p01.y /= ri.m_shrinkY;
TPointD translate = TPointD(tile.m_pos.x + tile.getRaster()->getLx() * 0.5,
tile.m_pos.y + tile.getRaster()->getLy() * 0.5);
glTranslated(-translate.x, -translate.y, 0.0);
// disegno il poligono
double dist_p00_p01 = tdistance2(p00, p01);
double dist_p10_p11 = tdistance2(p10, p11);
double dist_p01_p11 = tdistance2(p01, p11);
double dist_p00_p10 = tdistance2(p00, p10);
bool vertical = (dist_p00_p01 == dist_p10_p11);
bool horizontal = (dist_p00_p10 == dist_p01_p11);
if (vertical && horizontal) details = 1;
glPolygonMode(GL_FRONT_AND_BACK, polygonStyle);
subdivision(p00, p10, p11, p01, tex00, tex10, tex11, tex01, clippingRect,
details);
if (!wireframe) {
// abilito l'antialiasing delle linee
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
// disegno il bordo del poligono
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_QUADS);
glTexCoord2d(tex00.x, tex00.y);
tglVertex(p00);
glTexCoord2d(tex10.x, tex10.y);
tglVertex(p10);
glTexCoord2d(tex11.x, tex11.y);
tglVertex(p11);
glTexCoord2d(tex01.x, tex01.y);
tglVertex(p01);
glEnd();
// disabilito l'antialiasing per le linee
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
// force to finish
glFlush();
// rimetto il disegno dei poligoni a GL_FILL
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// metto il frame buffer nel raster del tile
glPixelStorei(GL_UNPACK_ROW_LENGTH, rasterWidth);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
TRaster32P newRas(tile.getRaster()->getLx(), tile.getRaster()->getLy());
newRas->lock();
glReadPixels(1, 1, newRas->getLx(), newRas->getLy(), GL_RGBA,
GL_UNSIGNED_BYTE, (void *)newRas->getRawData());
newRas->unlock();
checkErrorsByGL
rasaux->unlock();
tile.getRaster()->copy(newRas);
}
示例8: sl
void TLevelReader3gp::load(const TRasterP &rasP, int frameIndex, const TPoint &pos, int shrinkX, int shrinkY)
{
TRaster32P ras = rasP;
{
QMutexLocker sl(&m_mutex);
ras->lock();
if (m_IOError != QTNoError)
goto error;
Rect rect;
rect.right = pos.x + ras->getLx();
rect.left = pos.x;
rect.bottom = pos.y + ras->getLy();
rect.top = pos.y;
GWorldPtr offscreenGWorld;
OSErr err;
#if defined TNZ_MACHINE_CHANNEL_ORDER_BGRM
OSType pixelFormat = k32BGRAPixelFormat;
#elif defined TNZ_MACHINE_CHANNEL_ORDER_MRGB
OSType pixelFormat = k32ARGBPixelFormat;
#endif
err = QTNewGWorldFromPtr(
&offscreenGWorld, pixelFormat,
&rect, 0, 0, 0, ras->getRawData(), ras->getWrap() * 4);
if (err != noErr) {
m_IOError = QTUnableToCreateResource;
goto error;
}
SetMovieBox(m_movie, &rect);
err = GetMoviesError();
if (err != noErr) {
m_IOError = QTUnableToSetMovieBox;
#if 0
DisposeGWorld(offscreenGWorld);
#endif
goto error;
}
#if 0
SetMovieGWorld(m_movie, offscreenGWorld, GetGWorldDevice(offscreenGWorld));
#endif
err = GetMoviesError();
if (err != noErr) {
m_IOError = QTUnableToSetMovieGWorld;
#if 0
DisposeGWorld(offscreenGWorld);
#endif
goto error;
}
TimeValue currentTime = currentTimes[frameIndex];
SetMovieTimeValue(m_movie, currentTime);
err = GetMoviesError();
if (err != noErr) {
m_IOError = QTUnableToSetTimeValue;
#if 0
DisposeGWorld(offscreenGWorld);
#endif
goto error;
}
err = UpdateMovie(m_movie);
if (err != noErr) {
m_IOError = QTUnableToUpdateMovie;
#if 0
DisposeGWorld(offscreenGWorld);
#endif
goto error;
}
MoviesTask(m_movie, 0);
err = GetMoviesError();
if (err != noErr) {
m_IOError = QTUnableToDoMovieTask;
#if 0
DisposeGWorld(offscreenGWorld);
#endif
goto error;
}
SetMovieGWorld(m_movie, 0, 0);
#if 0
DisposeGWorld(offscreenGWorld);
#endif
ras->unlock();
}
if (m_depth != 32) {
setMatteAndYMirror(rasP);
} else {
rasP->yMirror();
}
//.........这里部分代码省略.........
示例9: tglDraw
//.........这里部分代码省略.........
double lhTex = 1.0;
TRaster32P texture;
unsigned int texLx = (unsigned int)tex->getLx();
unsigned int texLy = (unsigned int)tex->getLy();
if (texWidth != texLx ||
texHeight != texLy) {
texture = TRaster32P(texWidth, texHeight);
texture->fill(TPixel32(0, 0, 0, 0));
texture->copy(tex);
lwTex = (texLx) / (double)(texWidth);
lhTex = (texLy) / (double)(texHeight);
if (lwTex > 1.0)
lwTex = 1.0;
if (lhTex > 1.0)
lhTex = 1.0;
} else
texture = tex;
GLenum fmt =
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
GL_BGRA_EXT;
#elif TNZ_MACHINE_CHANNEL_ORDER_MBGR
GL_ABGR_EXT;
#elif TNZ_MACHINE_CHANNEL_ORDER_RGBM
GL_RGBA;
#elif TNZ_MACHINE_CHANNEL_ORDER_MRGB
GL_BGRA;
#else
// Error PLATFORM NOT SUPPORTED
#error "unknown channel order!"
#endif
// Generate a texture id and bind it.
GLuint texId;
glGenTextures(1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->getWrap());
texture->lock();
glTexImage2D(GL_TEXTURE_2D,
0,
4,
texWidth,
texHeight,
0,
fmt,
#ifdef TNZ_MACHINE_CHANNEL_ORDER_MRGB
GL_UNSIGNED_INT_8_8_8_8_REV,
#else
GL_UNSIGNED_BYTE,
#endif
texture->getRawData());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
double rectLx = rect.getLx();
double rectLy = rect.getLy();
tglColor(TPixel32(0, 0, 0, 0));
glPushMatrix();
glTranslated(rect.x0, rect.y0, 0.0);
glBegin(GL_POLYGON);
glTexCoord2d(0, 0);
tglVertex(TPointD(0.0, 0.0));
glTexCoord2d(lwTex, 0);
tglVertex(TPointD(rectLx, 0.0));
glTexCoord2d(lwTex, lhTex);
tglVertex(TPointD(rectLx, rectLy));
glTexCoord2d(0, lhTex);
tglVertex(TPointD(0.0, rectLy));
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
glPopAttrib();
// Delete texture
glDeleteTextures(1, &texId);
texture->unlock();
}
示例10: 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;
}
示例11: over
void TRop::over(TRaster32P rout, const TRasterGR8P &rup, const TPixel32 &color)
{
rout->lock();
do_over(rout, rup, color);
rout->unlock();
}