void TRasterImageUtils::addGlobalNumbering(const TRasterImageP &ri, const std::wstring &sceneName, int globalIndex) { if (!ri) return; TRasterP raster = ri->getRaster(); int lx = raster->getLx(), ly = raster->getLy(); QColor greyOverlay(100, 100, 100, 140); QImage image = rasterToQImage(raster, true, false); QPainter p(&image); QFont numberingFont = QFont(); numberingFont.setPixelSize(ly * 0.04); numberingFont.setBold(true); p.setFont(numberingFont); QMatrix matrix; p.setMatrix(matrix.translate(0, ly).scale(1, -1), true); QFontMetrics fm = p.fontMetrics(); int fontHeight = fm.height(); int offset = fontHeight * 0.2; QString globalFrame = QString::number(globalIndex); while (globalFrame.size() < 4) globalFrame.push_front("0"); QString globalNumberingString = QString::fromStdWString(sceneName) + ": " + globalFrame; int globalNumberingWidth = fm.width(globalNumberingString); p.setPen(Qt::NoPen); p.setBrush(QColor(255, 255, 255, 255)); p.drawRect(offset, ly - offset - fontHeight, globalNumberingWidth + offset * 2, fontHeight); p.setBrush(greyOverlay); p.drawRect(offset, ly - offset - fontHeight, globalNumberingWidth + offset * 2, fontHeight); p.setPen(Qt::white); p.drawText(2 * offset, ly - 2 * offset, globalNumberingString); p.end(); }
void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect) { TRasterImageP ri = TImageP(getImage(false, 1)); if (!ri) return; TRasterP ras = ri->getRaster(); TRect _rect = rect * ras->getBounds(); TRect _lastRect = m_lastRect * ras->getBounds(); if (_rect.isEmpty()) return; if (m_lastRect.isEmpty()) { m_workRaster->extract(_rect)->clear(); m_backUpRas->extract(_rect)->copy(ras->extract(_rect)); return; } QList<TRect> rects = ToolUtils::splitRect(_rect, _lastRect); for (int i = 0; i < rects.size(); i++) { m_workRaster->extract(rects[i])->clear(); m_backUpRas->extract(rects[i])->copy(ras->extract(rects[i])); } }
//! Returns for the first not-busy raster TRasterP RasterPool::getRaster() { QMutexLocker sl(&m_repositoryLock); RasterRepository::iterator it = m_rasterRepository.begin(); while (it != m_rasterRepository.end()) { RasterItem *rasItem = *it; if (rasItem->m_busy == false) { TRasterP raster = rasItem->getRaster(); if (!raster) { delete rasItem; m_rasterRepository.erase(it++); continue; } rasItem->m_busy = true; raster->clear(); return raster; } ++it; } RasterItem *rasItem = new RasterItem(m_size, m_bpp, true); m_rasterRepository.push_back(rasItem); return rasItem->getRaster(); }
void ShiftTraceTool::updateBox() { if (0 <= m_ghostIndex && m_ghostIndex < 2 && m_row[m_ghostIndex] >= 0) { int col = TApp::instance()->getCurrentColumn()->getColumnIndex(); int row = m_row[m_ghostIndex]; TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(row, col); TXshSimpleLevel *sl = cell.getSimpleLevel(); if (sl) { m_dpiAff = getDpiAffine(sl, cell.m_frameId); TImageP img = cell.getImage(false); if (img) { if (TRasterImageP ri = img) { TRasterP ras = ri->getRaster(); m_box = (convert(ras->getBounds()) - ras->getCenterD()) * ri->getSubsampling(); } else if (TToonzImageP ti = img) { TRasterP ras = ti->getRaster(); m_box = (convert(ras->getBounds()) - ras->getCenterD()) * ti->getSubsampling(); } else if (TVectorImageP vi = img) { m_box = vi->getBBox(); } } } } }
TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const { TToonzImageP ti = m_image; TRasterImageP ri = m_image; if (!!ri) // !!ti || !!ri) { TRasterP raster; //if(ti) // raster = ti->getRGBM(true); //else raster = ri->getRaster(); TPoint point = getRasterPoint(pos); if (!raster->getBounds().contains(point)) return TPixel32::Transparent; TRaster32P raster32 = raster; if (raster32) return raster32->pixels(point.y)[point.x]; TRasterGR8P rasterGR8 = raster; if (rasterGR8) return toPixel32(rasterGR8->pixels(point.y)[point.x]); } else if (TVectorImageP vi = m_image) { const TPalette *palette = m_palette.getPointer(); if (!palette) return TPixel32::Transparent; int styleId = pickStyleId(pos, radius2); if (0 <= styleId && styleId < palette->getStyleCount()) return palette->getStyle(styleId)->getAverageColor(); } return TPixel32::Transparent; }
inline TRasterP TCacheResource::createCellRaster(int rasterType, const std::string &cacheId) { TRasterP result; if (rasterType == TCacheResource::NONE) { assert(!"Unknown raster type!"); return result; } TImageP img; if (rasterType == TCacheResource::RGBM32) { result = TRaster32P(latticeStep, latticeStep); img = TRasterImageP(result); } else if (rasterType == TCacheResource::RGBM64) { result = TRaster64P(latticeStep, latticeStep); img = TRasterImageP(result); } else if (rasterType == TCacheResource::CM32) { result = TRasterCM32P(latticeStep, latticeStep); img = TToonzImageP(result, result->getBounds()); } TImageCache::instance()->add(cacheId, img); ++m_cellsCount; //DIAGNOSTICS_GLOADD("crCellsCnt", 1); return result; }
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(); }
void PlaneViewer::draw(TRasterP ras, double dpiX, double dpiY, TPalette *pal) { TPointD rasCenter(ras->getCenterD()); TRaster32P aux(rasterBuffer()); aux->lock(); ras->lock(); glGetDoublev(GL_MODELVIEW_MATRIX, m_matrix); TAffine viewAff(m_matrix[0], m_matrix[4], m_matrix[12], m_matrix[1], m_matrix[5], m_matrix[13]); viewAff = viewAff * TScale(Stage::inch / dpiX, Stage::inch / dpiY) * TTranslation(-rasCenter); pushGLWinCoordinates(); aux->clear(); if (pal) TRop::quickPut(aux, (TRasterCM32P)ras, pal, viewAff); else TRop::quickPut(aux, ras, viewAff); flushRasterBuffer(); popGLCoordinates(); }
TRect TRasterImageUtils::convertWorldToRaster(const TRectD &area, const TRasterImageP ri) { if (area.isEmpty()) return TRect(); if (!ri || !ri->getRaster()) return TRect(tfloor(area.x0), tfloor(area.y0), tfloor(area.x1) - 1, tfloor(area.y1) - 1); TRasterP ras = ri->getRaster(); TRectD rect(area + ras->getCenterD()); return TRect(tfloor(rect.x0), tfloor(rect.y0), tceil(rect.x1) - 1, tceil(rect.y1) - 1); }
void SceneViewer::onButtonPressed(FlipConsole::EGadget button) { if (m_freezedStatus != NO_FREEZED) return; switch (button) { case FlipConsole::eSaveImg: { if (m_previewMode == NO_PREVIEW) { DVGui::warning(QObject::tr( "It is not possible to save images in camera stand view.")); return; } TApp *app = TApp::instance(); int row = app->getCurrentFrame()->getFrame(); Previewer *previewer = Previewer::instance(m_previewMode == SUBCAMERA_PREVIEW); if (!previewer->isFrameReady(row)) { DVGui::warning(QObject::tr("The preview images are not ready yet.")); return; } TRasterP ras = previewer->getRaster(row, m_visualSettings.m_recomputeIfNeeded); TImageCache::instance()->add(QString("TnzCompareImg"), TRasterImageP(ras->clone())); break; } case FlipConsole::eSave: Previewer::instance(m_previewMode == SUBCAMERA_PREVIEW) ->saveRenderedFrames(); break; case FlipConsole::eHisto: { QAction *action = CommandManager::instance()->getAction(MI_Histogram); action->trigger(); break; } case FlipConsole::eDefineSubCamera: m_editPreviewSubCamera = !m_editPreviewSubCamera; update(); break; // open locator. Create one for the first time case FlipConsole::eLocator: if (!m_locator) m_locator = new LocatorPopup(this); m_locator->show(); m_locator->raise(); m_locator->activateWindow(); break; } }
void ShiftTraceTool::drawControlRect() { if (m_ghostIndex < 0 || m_ghostIndex > 1) return; int row = m_row[m_ghostIndex]; if (row < 0) return; int col = TApp::instance()->getCurrentColumn()->getColumnIndex(); TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(row, col); if (cell.isEmpty()) return; TImageP img = cell.getImage(false); if (!img) return; TRectD box; if (TRasterImageP ri = img) { TRasterP ras = ri->getRaster(); box = (convert(ras->getBounds()) - ras->getCenterD()) * ri->getSubsampling(); } else if (TToonzImageP ti = img) { TRasterP ras = ti->getRaster(); box = (convert(ras->getBounds()) - ras->getCenterD()) * ti->getSubsampling(); } else if (TVectorImageP vi = img) { box = vi->getBBox(); } else { return; } glPushMatrix(); tglMultMatrix(getGhostAff()); TPixel32 color; color = m_highlightedGadget == TranslateGadget ? TPixel32(200, 100, 100) : TPixel32(120, 120, 120); tglColor(color); glBegin(GL_LINE_STRIP); glVertex2d(box.x0, box.y0); glVertex2d(box.x1, box.y0); glVertex2d(box.x1, box.y1); glVertex2d(box.x0, box.y1); glVertex2d(box.x0, box.y0); glEnd(); color = m_highlightedGadget == 2000 ? TPixel32(200, 100, 100) : TPixel32::White; double r = 4 * sqrt(tglGetPixelSize2()); drawDot(box.getP00(), r, color); drawDot(box.getP01(), r, color); drawDot(box.getP10(), r, color); drawDot(box.getP11(), r, color); if (m_curveStatus == NoCurve) { color = m_highlightedGadget == 2001 ? TPixel32(200, 100, 100) : TPixel32::White; TPointD c = m_center[m_ghostIndex]; drawDot(c, r, color); } glPopMatrix(); }
TRasterP TRop::shrink(TRasterP rin, int shrink) { int pixelSize = rin->getPixelSize(); int lx = (rin->getLx() - 1) / shrink + 1; int ly = (rin->getLy() - 1) / shrink + 1; TRasterP rout; if ((TRaster32P)rin) rout = TRaster32P(lx, ly); else if ((TRaster64P)rin) rout = TRaster64P(lx, ly); if ((TRasterCM32P)rin) rout = TRasterCM32P(lx, ly); if ((TRasterGR8P)rin) rout = TRasterGR8P(lx, ly); int i, j; for (i = 0; i < ly; i++) { UCHAR *bufin = (UCHAR *)rin->getRawData() + (i * shrink) * rin->getWrap() * pixelSize; UCHAR *bufout = (UCHAR *)rout->getRawData() + i * rout->getWrap() * pixelSize; for (j = 0; j < lx; j++) { memcpy(bufout, bufin, pixelSize); bufin += shrink * pixelSize; bufout += pixelSize; } } return rout; }
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(); }
std::vector<TRect> TRasterImageUtils::paste(const TRasterImageP &ri, const TTileSetFullColor *tileSet) { std::vector<TRect> rects; TRasterP raster = ri->getRaster(); for (int i = 0; i < tileSet->getTileCount(); i++) { const TTileSetFullColor::Tile *tile = tileSet->getTile(i); TRasterP ras; tile->getRaster(ras); assert(ras); raster->copy(ras, tile->m_rasterBounds.getP00()); rects.push_back(tile->m_rasterBounds); } return rects; }
AdjustLevelsUndo::AdjustLevelsUndo(int *in0, int *in1, int *out0, int *out1, int r, int c, TRasterP ras) : m_r(r), m_c(c), m_rasSize(ras->getLx() * ras->getLy() * ras->getPixelSize()) { memcpy(m_in0, in0, sizeof(m_in0)); memcpy(m_in1, in1, sizeof(m_in1)); memcpy(m_out0, out0, sizeof(m_out0)); memcpy(m_out1, out1, sizeof(m_out1)); static int counter = 0; m_rasId = QString("AdjustLevelsUndo") + QString::number(++counter); TImageCache::instance()->add(m_rasId, TRasterImageP(ras)); }
void FullColorBrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) { m_brushPos = m_mousePos = pos; Viewer *viewer = getViewer(); if (!viewer) return; TRasterImageP ri = (TRasterImageP)getImage(true); if (!ri) ri = (TRasterImageP)touchImage(); if (!ri) return; TRasterP ras = ri->getRaster(); TDimension dim = ras->getSize(); if (!(m_workRaster && m_backUpRas)) setWorkAndBackupImages(); m_workRaster->lock(); double maxThick = m_thickness.getValue().second; double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThick; double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01; TPointD rasCenter = TPointD(dim.lx * 0.5, dim.ly * 0.5); TThickPoint point(pos + rasCenter, thickness); TPointD halfThick(maxThick * 0.5, maxThick * 0.5); TRectD invalidateRect(pos - halfThick, pos + halfThick); m_points.clear(); m_points.push_back(point); m_tileSet = new TTileSetFullColor(ras->getSize()); m_tileSaver = new TTileSaverFullColor(ras, m_tileSet); double hardness = m_hardness.getValue() * 0.01; m_brush = new BluredBrush(m_workRaster, maxThick, m_brushPad, hardness == 1.0); m_strokeRect = m_brush->getBoundFromPoints(m_points); updateWorkAndBackupRasters(m_strokeRect); m_tileSaver->save(m_strokeRect); m_brush->addPoint(point, opacity); m_brush->updateDrawing(ras, m_backUpRas, m_currentColor, m_strokeRect, m_opacity.getValue().second * 0.01); m_oldOpacity = opacity; m_lastRect = m_strokeRect; invalidate(invalidateRect.enlarge(2)); }
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(); }
void TRop::computeBBox(TRasterP ras, TRect &bbox) { TRaster32P ras32 = ras; if (ras32) { ::computeBBox<TPixel32, UCHAR>(ras32, bbox); return; } TRaster64P ras64 = ras; if (ras64) { ::computeBBox<TPixel64, USHORT>(ras64, bbox); return; } TRasterCM32P rasCM32 = ras; if (rasCM32) { computeBBoxCM32(rasCM32, bbox); return; } TRasterGR8P ras8 = ras; if (ras8) { bbox = ras->getBounds(); return; } assert(0); }
void TRop::over(const TRasterP &out, const TRasterP &up, const TPoint &pos, const TAffine &aff, ResampleFilterType filterType) { if (aff.isIdentity()) //simple over with offset TRop::over(out, up, pos); else { TRect rasterBounds = up->getBounds(); TRectD dbounds(rasterBounds.x0, rasterBounds.y0, rasterBounds.x1, rasterBounds.y1); dbounds = aff * dbounds; TRect bounds(tfloor(dbounds.x0), tfloor(dbounds.y0), tceil(dbounds.x1), tceil(dbounds.y1)); TRasterP tmp = up->create(bounds.getLx(), bounds.getLy()); resample(tmp, up, TTranslation(-dbounds.getP00()) * aff, filterType); TRop::over(out, tmp, pos); } }
void TRop::copy(TRasterP dst, const TRasterP &src) { assert(!((TRasterCM32P)src) || (TRasterCM32P)dst); if (dst->getPixelSize() == src->getPixelSize()) dst->copy(src); else { if (dst->getBounds() != src->getBounds()) { TRect rect = dst->getBounds() * src->getBounds(); if (rect.isEmpty()) return; TRop::convert(dst->extract(rect), src->extract(rect)); } else TRop::convert(dst, src); } }
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(); }
//! Copies the passed tile in the tile complex. The passed tile \b must //! possess integer geometry (ie tile.m_pos must have integer coordinates), //! otherwise this function is a no-op. bool TCacheResource::upload(const TPoint &pos, TRasterP ras) { int tileType; if (!checkRasterType(ras, tileType)) return false; if (m_tileType == NONE) m_tileType = tileType; //For all cells of the lattice which intersect the tile, upload the content in the //complex TRect tileRect(ras->getBounds() + pos); TPoint initialPos(getCellPos(tileRect.getP00())); //DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ", //"crStack", "upload", ::traduce(TRect(pos, ras->getSize()))); TPoint currPos; for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep) for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) { //Copy tile's content into the cell's raster. TRect cellRect(currPos, TDimension(latticeStep, latticeStep)); TRect overlapRect(tileRect * cellRect); assert(!overlapRect.isEmpty()); PointLess cellIndex(getCellIndex(currPos)); std::pair<TRasterP, CellData *> cellInfos(touch(cellIndex)); TRasterP cellRas(cellInfos.first); TRect temp(overlapRect - currPos); TRasterP overlappingCellRas(cellRas->extract(temp)); temp = TRect(overlapRect - tileRect.getP00()); TRasterP overlappingTileRas(ras->extract(temp)); assert(overlappingCellRas->getBounds() == overlappingTileRas->getBounds()); TRop::copy(overlappingCellRas, overlappingTileRas); cellInfos.second->m_modified = true; } //Update the complex's content region m_region += toQRect(tileRect); return true; }
bool TCacheResource::downloadAll(const TPoint &pos, TRasterP ras) { int tileType; if (!checkRasterType(ras, tileType)) return false; //Build the tile's rect TRect tileRect(ras->getBounds() + pos); if (!contains(m_region, tileRect)) return false; //DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ", //"crStack", "downloadAll", ::traduce(TRect(pos, ras->getSize()))); //For all cells intersecting the tile's rect, copy all those intersecting the //complex's content region. TPoint initialPos(getCellPos(tileRect.getP00())); TPoint currPos; for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep) for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) { TRect cellRect(currPos, TDimension(latticeStep, latticeStep)); TRect overlapRect(tileRect * cellRect); assert(!overlapRect.isEmpty()); QRect overlapQRect(toQRect(overlapRect)); if (m_region.intersects(overlapQRect)) { //Extract the associated rasters and perform the copy to the input tile. std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos))); TRasterP cellRas(cellInfos.first); TRect temp(overlapRect - currPos); TRasterP overlappingCellRas(cellRas->extract(temp)); temp = TRect(overlapRect - tileRect.getP00()); TRasterP overlappingTileRas(ras->extract(temp)); TRop::copy(overlappingTileRas, overlappingCellRas); } } return true; }
void FullColorBrushTool::setWorkAndBackupImages() { TRasterImageP ri = (TRasterImageP)getImage(false, 1); if (!ri) return; TRasterP ras = ri->getRaster(); TDimension dim = ras->getSize(); if (!m_workRaster || m_workRaster->getLx() > dim.lx || m_workRaster->getLy() > dim.ly) m_workRaster = TRaster32P(dim); if (!m_backUpRas || m_backUpRas->getLx() > dim.lx || m_backUpRas->getLy() > dim.ly || m_backUpRas->getPixelSize() != ras->getPixelSize()) m_backUpRas = ras->create(dim.lx, dim.ly); m_strokeRect.empty(); m_lastRect.empty(); }
void onRenderRasterCompleted(const RenderData &renderData) override { TRasterP outputRaster = renderData.m_rasA; TRasterImageP img(outputRaster->clone()); img->setDpi(m_cameraDpi.x, m_cameraDpi.y); if (m_outputImage) m_outputImage->setImg(img); else if (m_outputLevel) { std::vector<std::string> ids; for (int i = 0; i < (int)renderData.m_frames.size(); i++) { TFrameId fid((int)(renderData.m_frames[i]) + 1); m_outputLevel->setFrame(fid, img); std::string id = m_outputLevel->getSimpleLevel()->getImageId(fid); ids.push_back(id); } img = TImageP(); for (int i = 0; i < (int)ids.size(); i++) TImageCache::instance()->compress(ids[i]); } }
RasterFreeDeformer::RasterFreeDeformer(TRasterP ras) : FreeDeformer(), m_ras(ras), m_newRas(), m_noAntialiasing(false) { TRect r = ras->getBounds(); m_originalP00 = convert(r.getP00()); m_originalP11 = convert(r.getP11()); m_newPoints.push_back(m_originalP00); m_newPoints.push_back(convert(r.getP10())); m_newPoints.push_back(m_originalP11); m_newPoints.push_back(convert(r.getP01())); }
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(); }
//! Fills the passed tile with the data contained in the complex, returning //! the copied region. //! The same restriction of the upload() method applies here. QRegion TCacheResource::download(const TPoint &pos, TRasterP ras) { int tileType; if (!checkRasterType(ras, tileType)) return QRegion(); //Build the tile's rect TRect tileRect(ras->getBounds() + pos); if (!m_region.intersects(toQRect(tileRect))) return QRegion(); //For all cells intersecting the tile's rect, copy all those intersecting the //complex's content region. TPoint initialPos(getCellPos(tileRect.getP00())); TPoint currPos; for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep) for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) { TRect cellRect(currPos, TDimension(latticeStep, latticeStep)); TRect overlapRect(tileRect * cellRect); assert(!overlapRect.isEmpty()); QRect overlapQRect(toQRect(overlapRect)); if (m_region.intersects(overlapQRect)) { //Extract the associated rasters and perform the copy to the input tile. std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos))); TRasterP cellRas(cellInfos.first); TRect temp(overlapRect - currPos); TRasterP overlappingCellRas(cellRas->extract(temp)); temp = TRect(overlapRect - tileRect.getP00()); TRasterP overlappingTileRas(ras->extract(temp)); TRop::copy(overlappingTileRas, overlappingCellRas); } } return m_region.intersected(QRegion(toQRect(tileRect))); }
void Convert2Tlv::buildInksFromGrayTones(TRasterCM32P &rout, const TRasterP &rin) { int i, j; TRasterGR8P r8 = (TRasterGR8P)rin; TRaster32P r32 = (TRaster32P)rin; if (r8) for (i = 0; i < rin->getLy(); i++) { TPixelGR8 *pixin = r8->pixels(i); TPixelCM32 *pixout = rout->pixels(i); for (j = 0; j < rin->getLx(); j++, pixin++, pixout++) *pixout = TPixelCM32(1, 0, pixin->value); } else for (i = 0; i < rin->getLy(); i++) { TPixel *pixin = r32->pixels(i); TPixelCM32 *pixout = rout->pixels(i); for (j = 0; j < rin->getLx(); j++, pixin++, pixout++) *pixout = TPixelCM32(1, 0, TPixelGR8::from(*pixin).value); } }
void AntialiasPopup::setCurrentSampleRaster() { TRasterP sampleRas; m_startRas = TRasterP(); TSelection *selection = TApp::instance()->getCurrentSelection()->getSelection(); TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(selection); TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(selection); TImageP image; if (cellSelection) { TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(app->getCurrentFrame()->getFrameIndex(), app->getCurrentColumn()->getColumnIndex()); TImageP aux = cell.getImage(true); if (aux) image = aux->cloneImage(); } else if (filmstripSelection) { TApp *app = TApp::instance(); TXshSimpleLevel *simpleLevel = app->getCurrentLevel()->getSimpleLevel(); if (simpleLevel) { TImageP imageAux = simpleLevel->getFrame(app->getCurrentFrame()->getFid(), true); if (imageAux) image = imageAux->cloneImage(); } } if (!image || !(sampleRas = image->raster())) { m_viewer->setImage(TImageP()); m_viewer->update(); m_okBtn->setEnabled(false); return; } m_okBtn->setEnabled(true); m_startRas = sampleRas->clone(); onChange(m_startRas, sampleRas, m_thresholdField->getValue(), m_softnessField->getValue()); m_viewer->setImage(image); m_viewer->update(); }