本文整理汇总了C++中TRaster32P类的典型用法代码示例。如果您正苦于以下问题:C++ TRaster32P类的具体用法?C++ TRaster32P怎么用?C++ TRaster32P使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TRaster32P类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scale
void MeshTexturizer::Imp::allocateTextures(int groupIdx, const TRaster32P &ras, const TRaster32P &aux,
int x, int y, int textureLx, int textureLy,
bool premultiplied)
{
TextureData *data = m_textureDatas[groupIdx].get();
// Test the specified texture allocation
if (testTextureAlloc(textureLx, textureLy)) {
TPointD scale(data->m_geom.getLx() / (double)ras->getLx(),
data->m_geom.getLy() / (double)ras->getLy());
TRectD tileGeom(
TRectD(
scale.x * (x - TOTAL_BORDER), scale.y * (y - TOTAL_BORDER),
scale.x * (x + textureLx + TOTAL_BORDER), scale.y * (y + textureLy + TOTAL_BORDER)) +
data->m_geom.getP00());
GLuint texId = textureAlloc(ras, aux, x, y, textureLx, textureLy, premultiplied);
TextureData::TileData td = {texId, tileGeom};
data->m_tileDatas.push_back(td);
return;
}
if (textureLx <= 1 && textureLy <= 1)
return; // No texture can be allocated
// The texture could not be allocated. Then, bisecate and branch.
if (textureLx > textureLy) {
int textureLx_2 = textureLx >> 1;
allocateTextures(groupIdx, ras, aux, x, y, textureLx_2, textureLy, premultiplied);
allocateTextures(groupIdx, ras, aux, x + textureLx_2, y, textureLx_2, textureLy, premultiplied);
} else {
示例2: getRasterPoint
/*-- (StylePickerTool内で)LineとAreaを切り替えてPickできる。mode: 0=Area, 1=Line, 2=Line&Areas(default) --*/
int StylePicker::pickStyleId(const TPointD &pos, double radius2, int mode) const
{
int styleId = 0;
if (TToonzImageP ti = m_image) {
TRasterCM32P ras = ti->getRaster();
TPoint point = getRasterPoint(pos);
if (!ras->getBounds().contains(point))
return -1;
TPixelCM32 col = ras->pixels(point.y)[point.x];
switch (mode) {
case 0: //AREAS
styleId = col.getPaint();
break;
case 1: //LINES
styleId = col.getInk();
break;
case 2: //ALL (Line & Area)
default:
styleId = col.isPurePaint() ? col.getPaint() : col.getInk();
break;
}
} else if (TRasterImageP ri = m_image) {
const TPalette *palette = m_palette.getPointer();
if (!palette)
return -1;
TRaster32P ras = ri->getRaster();
if (!ras)
return -1;
TPoint point = getRasterPoint(pos);
if (!ras->getBounds().contains(point))
return -1;
TPixel32 col = ras->pixels(point.y)[point.x];
styleId = palette->getClosestStyle(col);
} else if (TVectorImageP vi = m_image) {
// prima cerca lo stile della regione piu' vicina
TRegion *r = vi->getRegion(pos);
if (r)
styleId = r->getStyle();
// poi cerca quello della stroke, ma se prima aveva trovato una regione, richiede che
// il click sia proprio sopra la stroke, altrimenti cerca la stroke piu' vicina (max circa 10 pixel)
const double maxDist2 = (styleId == 0) ? 100.0 * radius2 : 0;
bool strokeFound;
double dist2, w, thick;
UINT index;
//!funzionerebbe ancora meglio con un getNearestStroke che considera
//la thickness, cioe' la min distance dalla outline e non dalla centerLine
strokeFound = vi->getNearestStroke(pos, w, index, dist2);
if (strokeFound) {
TStroke *stroke = vi->getStroke(index);
thick = stroke->getThickPoint(w).thick;
if (dist2 - thick * thick < maxDist2) {
assert(stroke);
styleId = stroke->getStyle();
}
}
}
return styleId;
}
示例3:
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();
}
示例4: 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();
}
示例5: computeCentroid
TPoint computeCentroid(const TRaster32P &r) {
TPoint ret(1, 1);
TRasterGR8P raux(r->getLx() + 2, r->getLy() + 2);
if (fillByteRaster(r, raux)) doComputeCentroid(raux, ret);
ret.x--;
ret.y--; /* per il bordo aggiunto */
return ret;
}
示例6: addBackground32
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();
}
示例7: 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();
}
示例8: overPixOnWhite
void Naa2TlvConverter::setSourceImage(const TRaster32P &srcRas) {
int lx = srcRas->getSize().lx;
int ly = srcRas->getSize().ly;
m_colors.clear();
m_regions.clear();
delete m_regionRas;
m_regionRas = new WorkRaster<unsigned short>(lx, ly);
delete m_borderRas;
m_borderRas = 0;
delete m_dotRas;
m_dotRas = 0;
delete m_syntheticInkRas;
m_syntheticInkRas = 0;
QMap<TPixel32, int> colorTable;
for (int y = 0; y < ly; y++) {
TPixel32 *srcScanLine = srcRas->pixels(y);
unsigned short *regionScanLine = m_regionRas->pixels(y);
for (int x = 0; x < lx; x++) {
TPixel32 srcPix = overPixOnWhite(srcScanLine[x]);
QMap<TPixel32, int>::ConstIterator it = colorTable.find(srcPix);
if (it == colorTable.end()) {
// found new color (and therefore new region)
RegionInfo r;
// add new color
r.colorIndex = m_colors.count();
m_colors.append(srcPix);
r.pixelCount = 1;
// add new region
int regionIndex = m_regions.count();
m_regions.append(r);
// update raster and colorTable
regionScanLine[x] = regionIndex;
colorTable.insert(srcPix, regionIndex);
if (m_colors.count() > MaxColorCount) {
return;
}
} else {
// already defined color
int regionIndex = it.value();
regionScanLine[x] = regionIndex;
m_regions[regionIndex].pixelCount++;
}
}
}
m_valid = true;
}
示例9: do_over
void do_over(TRaster32P rout, const TRasterGR8P &rup, const TPixel32 &color)
{
assert(rout->getSize() == rup->getSize());
for (int y = rout->getLy(); --y >= 0;) {
TPixel32 *out_pix = rout->pixels(y);
TPixel32 *const out_end = out_pix + rout->getLx();
const TPixelGR8 *up_pix = rup->pixels(y);
for (; out_pix < out_end; ++out_pix, ++up_pix) {
double v = up_pix->value / 255.0;
TPixel32 up(troundp(v * color.r), troundp(v * color.g), troundp(v * color.b), troundp(v * color.m));
*out_pix = overPix(*out_pix, up);
}
}
}
示例10: my_do_over
//Usata tinylinetest
static void my_do_over(TRaster32P rout, const TRasterGR8P &rup)
{
assert(rout->getSize() == rup->getSize());
for (int y = rout->getLy(); --y >= 0;) {
TPixel32 *out_pix = rout->pixels(y);
TPixel32 *const out_end = out_pix + rout->getLx();
const TPixelGR8 *up_pix = rup->pixels(y);
for (; out_pix < out_end; ++out_pix, ++up_pix) {
int v = up_pix->value;
out_pix->r = out_pix->r * v / 255;
out_pix->g = out_pix->r;
out_pix->b = out_pix->r;
}
}
}
示例11: checkColor
QScriptValue ImageBuilder::fill(const QString &colorName) {
QColor color;
QScriptValue err = checkColor(context(), colorName, color);
if (err.isError()) return err;
TPixel32 pix(color.red(), color.green(), color.blue(), color.alpha());
if (m_img) {
if (m_img->getType() != TImage::RASTER)
context()->throwError("Can't fill a non-'Raster' image");
TRaster32P ras = m_img->raster();
if (ras) ras->fill(pix);
} else if (m_width > 0 && m_height > 0) {
TRaster32P ras(m_width, m_height);
ras->fill(pix);
m_img = TRasterImageP(ras);
}
return context()->thisObject();
}
示例12: clearMatte
static void clearMatte(const TRaster32P &ras, int xBegin, int yBegin, int xEnd, int yEnd)
{
for (int y = yBegin; y != yEnd; ++y) {
TPixel32 *line = ras->pixels(y), *pixEnd = line + xEnd;
for (TPixel32 *pix = line + xBegin; pix != pixEnd; ++pix)
pix->m = 0;
}
}
示例13: assert
TImageP ImageFiller::build(int imFlags, void *extData)
{
assert(imFlags == ImageManager::none);
// Fetch image
assert(extData);
ImageLoader::BuildExtData *data = (ImageLoader::BuildExtData *)extData;
assert(data->m_subs == 0);
const std::string &srcImgId = data->m_sl->getImageId(data->m_fid);
TImageP img = ImageManager::instance()->getImage(srcImgId, imFlags, extData);
if (img) {
TRasterImageP ri = img;
if (ri) {
TRaster32P ras = ri->getRaster();
if (ras) {
TRaster32P newRas = ras->clone();
FullColorAreaFiller filler(newRas);
TPaletteP palette = new TPalette();
int styleId = palette->getPage(0)->addStyle(TPixel32::White);
FillParameters params;
params.m_palette = palette.getPointer();
params.m_styleId = styleId;
params.m_minFillDepth = 0;
params.m_maxFillDepth = 15;
filler.rectFill(newRas->getBounds(), params, false);
TRasterImageP ri = TRasterImageP(newRas);
return ri;
}
}
}
// Error case: return a dummy image (is it really required?)
TRaster32P ras(10, 10);
ras->fill(TPixel32(127, 0, 127, 127));
return TRasterImageP(ras);
}
示例14: readbmp
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);
}
示例15: write
void Writer::write(const TRaster32P &ras, Processor *processor)
{
m_context->makeCurrent();
glClear(GL_COLOR_BUFFER_BIT);
if (ras) {
glRasterPos2d(0, 0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap());
glDrawPixels(ras->getLx(), ras->getLy(), TGL_FMT, TGL_TYPE, ras->getRawData());
}
if (processor) {
processor->draw();
}
glRasterPos2d(0, 0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap());
glReadPixels(0, 0, m_raster->getLx(), m_raster->getLy(), TGL_FMT, TGL_TYPE, m_raster->getRawData());
TImageP img = TRasterImageP(m_raster);
m_levelWriter->getFrameWriter(++m_frameCount)->save(img);
}