void Capture::update() { cvGrabFrame(m_capture); IplImage *frame = cvRetrieveFrame(m_capture); TmpBufferImage btmp(CV_8UC3); if ( frame != NULL ) { CvMat *mat = cvCreateMat(frame->height, frame->width, CV_8UC3); if ( m_invert ) { CvMat *tmp = btmp.getImage(frame->width, frame->height); cvConvertImage(frame, tmp, CV_CVTIMG_SWAP_RB); InvertImage(tmp, mat); } else { cvConvertImage(frame, mat, CV_CVTIMG_SWAP_RB); } m_wpipe.write(mat); } }
DenseIntVectSet& DenseIntVectSet::operator&=(const Box& b) { if (b.contains(m_domain) || b == m_domain || isEmpty()) { return *this; } if (!m_domain.intersects(b)) { *this = DenseIntVectSet(); return *this; } if (m_domain.numPts() < b.numPts()) { int i; BoxIterator bit(m_domain); for (i = 0, bit.begin(); bit.ok(); ++i, ++bit) { if (!b.contains(bit())) { m_bits.setFalse(i); } } } else { Box btmp(b); btmp &= m_domain; DenseIntVectSet tmp = DenseIntVectSet(btmp, true); int i; BoxIterator bit(btmp); for (i = 0, bit.begin(); bit.ok(); ++i, ++bit) { if (!this->operator[](bit())) { tmp.m_bits.setFalse(i); } } makeEmptyBits(); this->operator|=(tmp); } return *this; }
void ABec4::setCoefficients (const MultiFab &_a, const MultiFab &_b) { aCoefficients(_a); bCoefficients(_b); if (LO_Op) { int level = 0; const BoxArray& cba = boxArray(level); LO_Op->aCoefficients(_a); bool do_harm = true; for (int d=0; d<BL_SPACEDIM; ++d) { BoxArray eba = BoxArray(cba).surroundingNodes(d); MultiFab btmp(eba,1,0); lo_cc2ec(_b,btmp,0,0,1,d,do_harm); LO_Op->bCoefficients(btmp,d); } } }
void TileMapPanel::OnPaint(wxPaintEvent& event) { wxBitmap btmp(m_tileset->GetWxBitmap()); wxMemoryDC tilesetDC; tilesetDC.SelectObject(btmp); wxAutoBufferedPaintDC dc(this); DoPrepareDC(dc); wxPoint minPos = GetViewStart(); int width, height; GetClientSize(&width, &height); wxPoint maxPos = minPos + wxPoint(width, height); dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg); dc.DrawRectangle(minPos.x, minPos.y, width, height); if(!m_tilemap || !m_tileset || m_tileset->IsDirty()) return; dc.SetPen(wxPen(wxColor(128, 128, 128, 255), 1)); //Determine the first and last columns and rows to draw int firstCol = std::max((int)(minPos.x / m_tileset->tileSize.x - 1), 0); int firstRow = std::max((int)(minPos.y / m_tileset->tileSize.y - 1), 0); int lastCol = std::min((int)(maxPos.x / m_tileset->tileSize.x + 1), m_tilemap->GetColumnsCount()); int lastRow = std::min((int)(maxPos.y / m_tileset->tileSize.y + 1), m_tilemap->GetRowsCount()); //Draw the tiles for(int layer = 0; m_hideUpperLayers ? layer <= GetCurrentLayer() : layer < 3; layer++) { for(int col = firstCol; col < lastCol; col++) { for(int row = firstRow; row < lastRow; row++) { if(m_tilemap->GetTile(layer, col, row) == -1) continue; dc.Blit(GetPositionOfTile(col, row).x, GetPositionOfTile(col, row).y, m_tileset->tileSize.x, m_tileset->tileSize.y, &tilesetDC, m_tileset->GetTileTextureCoords(m_tilemap->GetTile(layer, col, row)).topLeft.x, m_tileset->GetTileTextureCoords(m_tilemap->GetTile(layer, col, row)).topLeft.y, wxCOPY, true); } } } //Draw the rectangle (when the mode is RectangleMode) if(m_insertionMode == RectangleMode && m_isDrawingRectangle) { dc.SetBrush(wxBrush(wxColour(128, 128, 255, 128))); dc.SetPen(wxPen(wxColor(128, 128, 255, 255), 1)); wxPoint topLeftPos(GetPositionOfTile(std::min(m_beginCol, m_endCol), std::min(m_beginRow, m_endRow))); wxPoint bottomRightPos(GetPositionOfTile(std::max(m_beginCol + 1, m_endCol + 1), std::max(m_beginRow + 1, m_endRow + 1))); wxSize rectSize(bottomRightPos.x - topLeftPos.x, bottomRightPos.y - topLeftPos.y); dc.DrawRectangle(topLeftPos, rectSize); } dc.SetPen(wxPen(wxColor(128, 128, 128, 255), 1)); //Draw the grid for(int col = firstCol; col < lastCol; col++) { dc.DrawLine(col * m_tileset->tileSize.x, minPos.y, col * m_tileset->tileSize.x, maxPos.y); for(int row = firstRow; row < lastRow; row++) { dc.DrawLine(minPos.x, row * m_tileset->tileSize.y, maxPos.x, row * m_tileset->tileSize.y); } } //Draw a gray rectangle outside the map dc.SetBrush(wxColor(128, 128, 128, 255)); if(maxPos.x > (m_tilemap->GetColumnsCount() * m_tileset->tileSize.x)) { dc.DrawRectangle(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, minPos.y, maxPos.x - m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, maxPos.y - minPos.y); } if(maxPos.y > (m_tilemap->GetRowsCount() * m_tileset->tileSize.y)) { dc.DrawRectangle(minPos.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y, maxPos.x - minPos.x, maxPos.y - m_tilemap->GetRowsCount() * m_tileset->tileSize.y); } }