本文整理汇总了C++中TRasterImageP::getRaster方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterImageP::getRaster方法的具体用法?C++ TRasterImageP::getRaster怎么用?C++ TRasterImageP::getRaster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRasterImageP
的用法示例。
在下文中一共展示了TRasterImageP::getRaster方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_gr_cum
void build_gr_cum(const TRasterImageP &image, int cum[256])
{
int lx, ly, wrap, true_lx, true_ly;
int i, x, y;
UCHAR *pix, *buffer;
int histo[256], raster_is_savebox;
get_virtual_buffer(image, &lx, &ly, &wrap, &buffer);
for (i = 0; i < 256; i++)
histo[i] = 0;
for (y = 0; y < ly; y++) {
pix = buffer + y * wrap;
for (x = 0; x < lx; x++)
histo[*pix++]++;
}
raster_is_savebox = 1;
TRect saveBox = image->getSavebox();
if ((saveBox.getLx() > 0 && saveBox.getLx() < image->getRaster()->getLx()) ||
(saveBox.getLy() > 0 && saveBox.getLy() < image->getRaster()->getLy()))
raster_is_savebox = 0;
if (raster_is_savebox) {
true_lx = saveBox.getLx() ? saveBox.getLx() : image->getRaster()->getLx();
true_ly = saveBox.getLy() ? saveBox.getLy() : image->getRaster()->getLy();
} else {
true_lx = image->getRaster()->getLx();
true_ly = image->getRaster()->getLy();
}
histo[255] += true_lx * true_ly - lx * ly;
build_cum(histo, cum);
}
示例2: QString
// note: create Undo BEFORE binarizing. Undo is keeping a copy of the current raster
TBinarizeUndo(TXshSimpleLevel *sl, const TFrameId &fid, bool alphaEnabled)
: m_levelName(sl->getName()), m_fid(fid), m_alphaEnabled(alphaEnabled)
{
/* FIXME: clang でコンパイルできなかったのでキャストにしたがこのダウンキャスト本当に大丈夫か? */
TRasterImageP ri = (TRasterImageP)sl->getFrame(m_fid, false)->cloneImage();
m_rasId = QString("BinarizeUndo") + QString::number((uintptr_t) this);
TImageCache::instance()->add(m_rasId, ri);
m_rasSize = ri->getRaster()->getLx() * ri->getRaster()->getLy() * 4;
}
示例3: convertWorldToRaster
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);
}
示例4: convertRasterToWorld
TRectD TRasterImageUtils::convertRasterToWorld(const TRect &area, const TRasterImageP ri)
{
if (area.isEmpty())
return TRectD();
TRectD rect(area.x0, area.y0, area.x1 + 1, area.y1 + 1);
if (ri && ri->getRaster())
rect = rect - ri->getRaster()->getCenterD();
return rect;
}
示例5: leftButtonUp
void FullColorBrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e)
{
m_brushPos = m_mousePos = pos;
TRasterImageP ri = (TRasterImageP)getImage(true);
if (!ri)
return;
if (m_points.size() != 1) {
double maxThickness = m_thickness.getValue().second;
double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness;
double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
TPointD rasCenter = ri->getRaster()->getCenterD();
TThickPoint point(pos + rasCenter, thickness);
m_points.push_back(point);
int m = m_points.size();
vector<TThickPoint> points;
points.push_back(m_points[m - 3]);
points.push_back(m_points[m - 2]);
points.push_back(m_points[m - 1]);
TRect bbox = m_brush->getBoundFromPoints(points);
updateWorkAndBackupRasters(bbox);
m_tileSaver->save(bbox);
m_brush->addArc(points[0], points[1], points[2], m_oldOpacity, opacity);
m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01);
TRectD invalidateRect = ToolUtils::getBounds(points, maxThickness);
invalidate(invalidateRect.enlarge(2) - rasCenter);
m_strokeRect += bbox;
m_lastRect.empty();
}
if (m_brush) {
delete m_brush;
m_brush = 0;
}
m_workRaster->unlock();
if (m_tileSet->getTileCount() > 0) {
delete m_tileSaver;
TTool::Application *app = TTool::getApplication();
TXshLevel *level = app->getCurrentLevel()->getLevel();
TXshSimpleLevelP simLevel = level->getSimpleLevel();
TFrameId frameId = getCurrentFid();
TRasterP ras = ri->getRaster()->extract(m_strokeRect)->clone();
TUndoManager::manager()->add(new FullColorBrushUndo(m_tileSet, simLevel.getPointer(), frameId,
m_isFrameCreated, ras, m_strokeRect.getP00()));
}
notifyImageChanged();
m_strokeRect.empty();
}
示例6: undo
void undo() const
{
TXshSimpleLevel *sl = getLevel();
if (!sl)
return;
TRasterImageP ri = sl->getFrame(m_fid, true);
if (!ri)
return;
TRasterImageP oldRaster = TImageCache::instance()->get(m_rasId, false);
ri->getRaster()->copy(oldRaster->getRaster());
notify(sl);
}
示例7: panQt
/*! Add to current trasformation matrix a \b delta traslation.
*/
void ImageViewer::panQt(const QPoint &delta) {
if (delta == QPoint()) return;
// stop panning when the image is at the edge of window
QPoint delta_(delta.x(), delta.y());
TToonzImageP timg = (TToonzImageP)m_image;
TRasterImageP rimg = (TRasterImageP)m_image;
if (timg || rimg) {
bool isXPlus = delta.x() > 0;
bool isYPlus = delta.y() > 0;
TDimension imgSize((timg) ? timg->getSize() : rimg->getRaster()->getSize());
int subSampling = (timg) ? timg->getSubsampling() : rimg->getSubsampling();
TPointD cornerPos = TPointD(imgSize.lx * ((isXPlus) ? -1 : 1),
imgSize.ly * ((isYPlus) ? 1 : -1)) *
(0.5 / (double)subSampling);
cornerPos = m_viewAff * cornerPos;
if ((cornerPos.x > 0) == isXPlus) delta_.setX(0);
if ((cornerPos.y < 0) == isYPlus) delta_.setY(0);
}
setViewAff(TTranslation(delta_.x(), -delta_.y()) * m_viewAff);
update();
}
示例8: addGlobalNumbering
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();
}
示例9: pickColor
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;
}
示例10: updateWorkAndBackupRasters
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]));
}
}
示例11: getSelectedFrames
int BinarizePopup::getSelectedFrames()
{
m_frames.clear();
TSelection *selection = TSelection::getCurrent();
TCellSelection *cellSelection;
TFilmstripSelection *filmstripSelection;
int count = 0;
if ((cellSelection = dynamic_cast<TCellSelection *>(selection))) {
std::set<TRasterImage *> images;
int r0, c0, r1, c1;
cellSelection->getSelectedCells(r0, c0, r1, c1);
TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
int c, r;
for (c = c0; c <= c1; c++) {
for (r = r0; r <= r1; r++) {
TXshCell cell = xsheet->getCell(r, c);
TRasterImageP rasImage = cell.getImage(false);
if (!rasImage || !rasImage->getRaster())
continue;
Frames::value_type item(cell.getSimpleLevel(), cell.getFrameId());
Frames::iterator it;
it = std::lower_bound(m_frames.begin(), m_frames.end(), item);
if (it == m_frames.end() || *it != item) {
m_frames.insert(it, item);
count++;
}
}
}
} else if ((filmstripSelection = dynamic_cast<TFilmstripSelection *>(selection))) {
TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
if (sl) {
std::set<TFrameId> fids = filmstripSelection->getSelectedFids();
std::set<TFrameId>::iterator it;
for (it = fids.begin(); it != fids.end(); ++it) {
TRasterImageP rasImage = sl->getFrame(*it, false);
if (!!rasImage && !!rasImage->getRaster()) {
m_frames.push_back(std::make_pair(sl, *it));
count++;
}
}
}
} else {
}
m_frameIndex = 0;
return count;
}
示例12: draw
void PlaneViewer::draw(TRasterImageP ri) {
double dpiX, dpiY;
ri->getDpi(dpiX, dpiY);
if (dpiX == 0.0 || dpiY == 0.0) dpiX = dpiY = Stage::inch;
draw(ri->getRaster(), dpiX, dpiY);
}
示例13: leftButtonDrag
void FullColorBrushTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
{
m_brushPos = m_mousePos = pos;
TRasterImageP ri = (TRasterImageP)getImage(true);
if (!ri)
return;
double maxThickness = m_thickness.getValue().second;
double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness;
double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
TDimension size = m_workRaster->getSize();
TPointD rasCenter = TPointD(size.lx * 0.5, size.ly * 0.5);
TThickPoint point(pos + rasCenter, thickness);
TThickPoint old = m_points.back();
if (norm2(point - old) < 4)
return;
TThickPoint mid((old + point) * 0.5, (point.thick + old.thick) * 0.5);
m_points.push_back(mid);
m_points.push_back(point);
TRect bbox;
int m = m_points.size();
TRectD invalidateRect;
if (m == 3) {
// ho appena cominciato. devo disegnare un segmento
TThickPoint pa = m_points.front();
vector<TThickPoint> points;
points.push_back(pa);
points.push_back(mid);
invalidateRect = ToolUtils::getBounds(points, maxThickness);
bbox = m_brush->getBoundFromPoints(points);
updateWorkAndBackupRasters(bbox + m_lastRect);
m_tileSaver->save(bbox);
m_brush->addArc(pa, (pa + mid) * 0.5, mid, m_oldOpacity, opacity);
m_lastRect += bbox;
} else {
// caso generale: disegno un arco
vector<TThickPoint> points;
points.push_back(m_points[m - 4]);
points.push_back(old);
points.push_back(mid);
invalidateRect = ToolUtils::getBounds(points, maxThickness);
bbox = m_brush->getBoundFromPoints(points);
updateWorkAndBackupRasters(bbox + m_lastRect);
m_tileSaver->save(bbox);
m_brush->addArc(m_points[m - 4], old, mid, m_oldOpacity, opacity);
m_lastRect += bbox;
}
m_oldOpacity = opacity;
m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01);
invalidate(invalidateRect.enlarge(2) - rasCenter);
m_strokeRect += bbox;
}
示例14: leftButtonDrag
void RasterSelectionTool::leftButtonDrag(const TPointD &pos,
const TMouseEvent &e) {
if (m_setSaveboxTool && m_modifySavebox.getValue()) {
m_setSaveboxTool->leftButtonDrag(pos);
invalidate();
return;
}
if (m_dragTool) {
m_dragTool->leftButtonDrag(pos, e);
invalidate();
return;
}
TImageP image = getImage(true);
TToonzImageP ti = (TToonzImageP)image;
TRasterImageP ri = (TRasterImageP)image;
if (!ti && !ri) return;
if (m_selecting) {
if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
TDimension imageSize;
if (ti)
imageSize = ti->getSize();
else if (ri)
imageSize = ri->getRaster()->getSize();
TPointD p(imageSize.lx % 2 ? 0.5 : 0.0, imageSize.ly % 2 ? 0.5 : 0.0);
TRectD rectD(tround(std::min(m_firstPos.x, pos.x) - p.x) + p.x,
tround(std::min(m_firstPos.y, pos.y) - p.y) + p.y,
tround(std::max(m_firstPos.x, pos.x) - p.x) + p.x,
tround(std::max(m_firstPos.y, pos.y) - p.y) + p.y);
m_selectingRect = rectD;
m_bboxs.clear();
invalidate();
} else if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
freehandDrag(pos);
return;
}
double pixelSize = getPixelSize();
TTool::Application *app = TTool::getApplication();
if (!app || m_justSelected || !m_selecting ||
tdistance2(pos, m_curPos) < 9.0 * pixelSize * pixelSize)
return;
m_curPos = pos;
if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
freehandDrag(pos);
else if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
bool selectOverlappingStroke = (m_firstPos.x > pos.x);
TRectD rect(m_firstPos, pos);
m_selectingRect = rect;
invalidate();
}
}
示例15: addStroke
TRect TRasterImageUtils::addStroke(const TRasterImageP &ri, TStroke *stroke, TRectD clip,
double opacity, bool doAntialiasing)
{
TStroke *s = new TStroke(*stroke);
TPoint riCenter = ri->getRaster()->getCenter();
s->transform(TTranslation(riCenter.x, riCenter.y));
TRect rect = fastAddInkStroke(ri, s, clip, opacity, doAntialiasing);
rect -= riCenter;
delete s;
return rect;
}