本文整理汇总了C++中TRaster32P::getWrap方法的典型用法代码示例。如果您正苦于以下问题:C++ TRaster32P::getWrap方法的具体用法?C++ TRaster32P::getWrap怎么用?C++ TRaster32P::getWrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRaster32P
的用法示例。
在下文中一共展示了TRaster32P::getWrap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
FullColorAreaFiller::FullColorAreaFiller(const TRaster32P &ras)
: m_ras(ras)
, m_bounds(ras->getBounds())
, m_pixels(ras->pixels())
, m_wrap(ras->getWrap())
, m_color(0) {
m_ras->lock();
}
示例3: brush
//.........这里部分代码省略.........
}
// ----- 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);
int xMin = tmax(xLeft - halfCord.getCord(deltay), 0); // clipping x
int xMax = tmin(xRight + 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 verticale (a.x = b.x, a.y != b.y)
if (a.x == b.x) {
int xMin = tmax(a.x - radius, 0); // clipping x
int xMax = tmin(a.x + radius, lx - 1); // clipping x
for (x = xMin; x <= xMax; x++) {
int deltax = abs(x - a.x);
int yMin = tmax(a.y - halfCord.getCord(deltax), 0); // clipping y
int yMax = tmin(b.y + halfCord.getCord(deltax), ly - 1); // clipping y
if (yMin <= yMax) {
TPixel32 *p = ras->pixels(yMin) + x;
TPixel32 *q = ras->pixels(yMax) + x;
int wrap = ras->getWrap();
while (p <= q) {
*p = col;
p += wrap;
}
}
}
ras->unlock();
return;
}
// ----- rettangolo inclinato
// k = +1/-1 se il rettangolo e' inclinato positivamente/negativamente
int k = 1;
int dx = b.x - a.x;
if (dx < 0) {
dx = -dx;
k = -1;
}
int dy = b.y - a.y;
assert(dx > 0);
assert(dy > 0);
double length = sqrt((double)(dx * dx + dy * dy));
const double m = dy / (double)dx;
//punto di tangenza superiore nel sistema di riferimento del cerchio
TPointD up(-radius * dy / length, radius * dx / length);
//semi-ampiezza orizzontale delle "calotte" circolari
int halfAmplCap = tfloor(-up.x);
示例4: findNearestColor
void Convert2Tlv::doFill(TRasterCM32P &rout, const TRaster32P &rin)
{
//prima passata: si filla solo partendo da pixel senza inchiostro, senza antialiasing(tone==255)
for (int i = 0; i < rin->getLy(); i++) {
TPixel *pixin = rin->pixels(i);
TPixelCM32 *pixout = rout->pixels(i);
for (int j = 0; j < rin->getLx(); j++, pixin++, pixout++) {
if (!(pixout->getTone() == 255 && pixout->getPaint() == 0 && pixin->m == 255))
continue;
std::map<TPixel, int>::const_iterator it;
int paintIndex;
if ((it = m_colorMap.find(*pixin)) == m_colorMap.end()) {
if (m_colorTolerance > 0)
it = findNearestColor(*pixin);
// if (it==colorMap.end() && (int)colorMap.size()>origColorCount) //se non l'ho trovato tra i colori origari, lo cerco in quelli nuovi, ma in questo caso deve essere esattamente uguale(tolerance = 0)
// it = findNearestColor(*pixin, colorMap, colorTolerance, origColorCount, colorMap.size()-1);
if (it == m_colorMap.end() && m_lastIndex < 4096) {
m_colorMap[*pixin] = ++m_lastIndex;
paintIndex = m_lastIndex;
} else if (it != m_colorMap.end()) {
m_colorMap[*pixin] = it->second;
paintIndex = it->second;
}
} else
paintIndex = it->second;
FillParameters params;
params.m_p = TPoint(j, i);
params.m_styleId = paintIndex;
params.m_emptyOnly = true;
fill(rout, params);
//if (*((ULONG *)rout->getRawData())!=0xff)
// {
// int cavolo=0;
// }
}
}
//seconda passata: se son rimasti pixel antialiasati non fillati, si fillano, cercando nelle vicinanze un pixel di paint puro per capire il colore da usare
for (int i = 0; i < rin->getLy(); i++) {
TPixel *pixin = rin->pixels(i);
TPixelCM32 *pixout = rout->pixels(i);
for (int j = 0; j < rin->getLx(); j++, pixin++, pixout++) {
if (!(pixout->getTone() > 0 && pixout->getTone() < 255 && pixout->getPaint() == 0 && pixin->m == 255))
continue;
TPoint p = getClosestPurePaint(rout, i, j);
if (p.x == -1)
continue;
//pixout->setPaint( paintIndex);
FillParameters params;
params.m_p = TPoint(j, i);
params.m_styleId = (rout->pixels(p.y) + p.x)->getPaint();
params.m_emptyOnly = true;
fill(rout, params);
}
}
//infine, si filla di trasparente lo sfondo, percorrendo il bordo, nel caso di trasbordamenti di colore
TPixelCM32 *pixCm;
TPixel *pix;
pixCm = rout->pixels(0);
pix = rin->pixels(0);
FillParameters params;
params.m_styleId = 0;
for (int i = 0; i < rout->getLx(); i++, pixCm++, pix++)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(i, 0);
fill(rout, params);
}
pixCm = rout->pixels(rout->getLy() - 1);
pix = rin->pixels(rout->getLy() - 1);
for (int i = 0; i < rout->getLx(); i++, pixCm++, pix++)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(i, rout->getLy() - 1);
fill(rout, params);
}
int wrapCM = rout->getWrap();
int wrap = rin->getWrap();
pixCm = rout->pixels(0);
pix = rin->pixels(0);
for (int i = 0; i < rin->getLy(); i++, pixCm += wrapCM, pix += wrap)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(0, i);
fill(rout, params);
}
pixCm = rout->pixels(0) + rout->getLx() - 1;
pix = rin->pixels(0) + rin->getLx() - 1;
for (int i = 0; i < rin->getLy(); i++, pixCm += wrapCM, pix += wrap)
if (pixCm->getTone() == 255 && pixCm->getPaint() != 0 && pix->m == 0) {
params.m_p = TPoint(rout->getLx() - 1, i);
fill(rout, params);
}
//.........这里部分代码省略.........
示例5: 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();
}
//.........这里部分代码省略.........
示例6: tglDraw
void tglDraw(const TRectD &rect, const TRaster32P &tex, bool blending)
{
CHECK_ERRORS_BY_GL;
glPushAttrib(GL_ALL_ATTRIB_BITS);
if (blending) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
unsigned int texWidth = 1;
unsigned int texHeight = 1;
while (texWidth < (unsigned int)tex->getLx())
texWidth = texWidth << 1;
while (texHeight < (unsigned int)tex->getLy())
texHeight = texHeight << 1;
double lwTex = 1.0;
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);
//.........这里部分代码省略.........