GC3Denum WebGLFramebuffer::checkStatus() const { unsigned int count = 0; GC3Dsizei width = 0, height = 0; if (isDepthAttached()) { if (!isAttachmentComplete(m_depthAttachment.get(), GraphicsContext3D::DEPTH_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; width = getImageWidth(m_depthAttachment.get()); height = getImageHeight(m_depthAttachment.get()); count++; } if (isStencilAttached()) { if (!isAttachmentComplete(m_stencilAttachment.get(), GraphicsContext3D::STENCIL_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!count) { width = getImageWidth(m_stencilAttachment.get()); height = getImageHeight(m_stencilAttachment.get()); } else { if (width != getImageWidth(m_stencilAttachment.get()) || height != getImageHeight(m_stencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } count++; } if (isDepthStencilAttached()) { if (!isAttachmentComplete(m_depthStencilAttachment.get(), GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT)) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!isValidRenderbuffer(m_depthStencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; if (!count) { width = getImageWidth(m_depthStencilAttachment.get()); height = getImageHeight(m_depthStencilAttachment.get()); } else { if (width != getImageWidth(m_depthStencilAttachment.get()) || height != getImageHeight(m_depthStencilAttachment.get())) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } count++; } // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. if (count > 1) return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; if (isColorAttached()) { // FIXME: if color buffer is texture, is ALPHA, LUMINANCE or LUMINANCE_ALPHA valid? if (!getColorBufferFormat()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; if (!count) { if (!getColorBufferWidth() || !getColorBufferHeight()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; } else { if (width != getColorBufferWidth() || height != getColorBufferHeight()) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS; } } else { if (!count) return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; } return GraphicsContext3D::FRAMEBUFFER_COMPLETE; }
void FillColorMenuToolButton::drawImageSurface(const Cairo::RefPtr<Cairo::Context> context) { Gdk::Cairo::set_source_pixbuf (context, pixbuf_, 3.0, 0.0); context->paint(); drawColorRectangle (context, 0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5); }
/*! \brief Returns the meters per pixel. */ double SceneryMap::getScaling() const { if (!scaling_) { scaling_ = getWidth() / getImageWidth(); } return scaling_; }
std::vector<Eigen::Vector3f> ImageReader::toVector(){ std::vector<Eigen::Vector3f> output; for (int i = 0; i < getImageHeight(); i++) { for (int j = 0; j < getImageWidth(); j++) { QColor pixelColor = QColor(pixelAt(i,j)); Eigen::Vector3f color = Eigen::Vector3f(float(pixelColor.red()), float(pixelColor.green()), float(pixelColor.blue())); output.push_back(color); } } return output; }
void draw(void *userData) { DemoData *d = (DemoData *) userData; char buf[256]; int x, y; /* Exit on key press */ if (getKey()) exitPolo(); /* Clear screen with right mouse button */ if (isMouseButtonPressed(1)) clearScreen(); /* Paint with left mouse button */ if (isMouseButtonPressed(0)) { if ((getMouseX() < 128) && (getMouseY() < 128)) setDrawTint(getColorFromHSVA(getMouseX() / 128, getMouseY() / 128, 1, BRUSH_ALPHA)); else drawImage(getMouseX() - getImageWidth(d->brush) / 2, getMouseY() - getImageHeight(d->brush) / 2, d->brush); } /* Draw left bar */ setPenColor(POLO_STEEL); setFillGradient(POLO_SILVER, POLO_TUNGSTEN); drawRect(-1, -1, TOOLBAR_WIDTH, getScreenHeight() + 2); /* Draw frames per second and time display */ setPenColor(POLO_BLACK); sprintf(buf, "FPS: %.3f", d->frame / (getTime() + 0.001)); drawText((TOOLBAR_WIDTH - getTextDrawWidth(buf)) / 2, getScreenHeight() - getTextDrawHeight(buf) - 10, buf); /* Increment frame number */ d->frame++; /* Paint color palette */ for (x = 0; x < 128; x++) for (y = 0; y < 128; y++) { setPenColor(getColorFromHSV(x / 128.0, y / 128.0, 1.0)); drawPoint(x, y); } }
void ColorMenuToolButtonBase::drawColorRectangle(const Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h) { if (has_color_) { context->rectangle (0, getImageHeight() - 5, getImageWidth(), 5); #ifdef GTKMM_3 selected_color_.useInCairo (context); #else selected_color_.useInCairoRev (context); #endif context->fill(); } else { context->set_line_width (1.0); context->rectangle (0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5); context->set_source_rgb (0, 0, 0); context->stroke(); } }
void ImageReader::findMinAndMax() { int min = 10000000000; int max = -1; for (int i = 0; i < getImageHeight(); i++) { for (int j = 0; j < getImageWidth(); j++) { if (QColor(pixelAt(i,j)).red() > 150) { if (j > max) { max = j; } if (j < min) { min = j; } } } } assert(max > min); m_xMax = max; m_xMin = min; }
void Layout::update(const AlbumItemContainer &items, const Size2i &clientSize, ImageCache &imageCache) { updateCellLayout(); lines_.clear(); itemCount_ = items.size(); columns_ = std::max(1, (clientSize.w + columnSpace_) / cellStepX_); typedef AlbumItemContainer::const_iterator ItemIt; class LineDivider { const unsigned int columns_; const ItemIt beg_; const ItemIt end_; ItemIt curr_; public: LineDivider(unsigned int columns, const ItemIt &beg, const ItemIt &end) : columns_(columns), beg_(beg), end_(end), curr_(beg) {} bool isTerminated() const { return curr_ == end_;} const ItemIt &getCurrent() const { return curr_;} ItemIt getLineEnd() { unsigned int count = 0; for(;;){ if(curr_ == end_){ return curr_; } if((*curr_)->isLineBreak()){ const ItemIt lineEnd = curr_; ++curr_; return lineEnd; } if(count++ >= columns_){ return curr_; } ++curr_; } } }; LineDivider lineDivider(columns_, items.begin(), items.end()); int lineTop = 0; while(!lineDivider.isTerminated()){ const ItemIt lineBeg = lineDivider.getCurrent(); const ItemIt lineEnd = lineDivider.getLineEnd(); // 画像の高さがAUTOの場合、行内の最大の画像の高さを求める。 if(isImageHeightAuto()){ const int maxImageHeight = std::accumulate(lineBeg, lineEnd, 0, [&](int maxImageHeight, const AlbumItemPtr &item) -> int { switch(item->getType()){ case AlbumItem::TYPE_LINE_BREAK: break; case AlbumItem::TYPE_PICTURE: if(const AlbumPicture *pic = dynamic_cast<const AlbumPicture *>(item.get())){ if(const ImagePtr im = imageCache.getImage(pic->getFilePath(), Size2i(getImageWidth(), getImageHeight()))){ return std::max(maxImageHeight, im->getHeight()); } } break; } return maxImageHeight; }); lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, maxImageHeight))); lineTop += maxImageHeight + nameHeight_ + lineSpace_; } else{ lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, imageHeight_))); lineTop += cellStepY_; } } pageSize_.set( columns_ * cellStepX_ - columnSpace_, lineTop ? lineTop - lineSpace_ : 0); }
int main(int argc, char** argv) { float** testRedChannel = generateImageArray("red.txt"); float** testGreenChannel = generateImageArray("green.txt"); float** testBlueChannel = generateImageArray("blue.txt"); int h = getImageWidth("red.txt"); int w = getImageHeight("red.txt"); printf("%i rows x %i columns\n", h, w); /////////////////////////////////////////////////////////// //////Compute the l1-norm distance of neighbor pixels.///// /////////////////////////////////////////////////////////// float** dIcdxRed = diffH(testRedChannel, h,w); float** dIcdxGreen = diffH(testGreenChannel, h,w); float** dIcdxBlue = diffH(testBlueChannel, h,w); float** dIcdx = addChannels(dIcdxRed, dIcdxGreen, dIcdxBlue, h,w); destroyArray(dIcdxRed); destroyArray(dIcdxGreen); destroyArray(dIcdxBlue); float** dIcdyRed = diffV(testRedChannel, h,w); float** dIcdyGreen = diffV(testGreenChannel, h,w); float** dIcdyBlue = diffV(testBlueChannel, h,w); float** dIcdy = addChannels(dIcdyRed, dIcdyGreen, dIcdyBlue, h,w); destroyArray(dIcdyRed); destroyArray(dIcdyGreen); destroyArray(dIcdyBlue); /////////////////////////////////////////////////////////// ///////Compute the derivatives of the horizontal/////////// ///////and vertical domain transforms.///////////////////// /////////////////////////////////////////////////////////// float factor = sigma_s / sigma_r; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { dIcdx[i][j] = 1 + factor * dIcdx[i][j]; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { dIcdy[i][j] = 1 + factor * dIcdy[i][j]; } } ///The vertical pass is performed using a transposed image. float** dHdyT = transpose(dIcdy, h, w); destroyArray(dIcdy); /////////////////////////////////////////////////////////// ///////////////////Perform the filtering.////////////////// /////////////////////////////////////////////////////////// filtering(testRedChannel, dIcdx, dHdyT, h, w, 10); filtering(testGreenChannel, dIcdx, dHdyT, h, w, 10); filtering(testBlueChannel, dIcdx, dHdyT, h, w, 10); /////////////////////////////////////////////////////////// ///////////////////GENERATE OUTPUT IMAGE/////////////////// /////////////////////////////////////////////////////////// generateImageFile(testRedChannel, "outred.txt", h, w); generateImageFile(testGreenChannel, "outgreen.txt", h, w); generateImageFile(testBlueChannel, "outblue.txt", h, w); /////////////////////////////////////////////////////////// ///////////////////////FREE MEMORY///////////////////////// /////////////////////////////////////////////////////////// destroyArray(dIcdx); destroyArray(dHdyT); destroyArray(testRedChannel); destroyArray(testGreenChannel); destroyArray(testBlueChannel); return 0; }