Ejemplo n.º 1
0
	void save_image(
		cell cells[GRID_W][GRID_H],
		Vec2 particles[PARTICLES_NUM],
		std::string filename) {
		int w = GRID_W;
		int h = GRID_H;
		
		rgb8_image_t img(w, h);
		
		rgb8_image_t::view_t v = view(img);
		
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				cell * cell = &cells[i][j];
				Vec2 * cu = &cell->u;
				
				v(i,j) = rgb8_pixel_t(cu->x * 255 + 128, cu->y * 255 + 128, 0);
				//v(i,j) = rgb8_pixel_t(0, 0, 0);
			}
		}

		for(int i = 0; i < PARTICLES_NUM; i++){
			int posi = particles[i].x;
			int posj = particles[i].y;
			
			if(posi < 0 || posi >= w || posj < 0 || posj >= h){
				continue;
			}
			
			v(posi, posj) = rgb8_pixel_t(255, 255, 255);
		}
		
		png_write_view(filename, const_view(img));
	}
Ejemplo n.º 2
0
void ImageGetter::resizePNGImage(std::string const& imageURL, int sixex, int sizey)
{
	
	boost::gil::rgb8_image_t img;
	png_read_image(imageURL,img);
	

    boost::gil::rgb8_image_t targetImageSize(sixex,sizey);

    resize_view(const_view(img), view(targetImageSize), boost::gil::bilinear_sampler());
    png_write_view(imageURL,const_view(targetImageSize));

}
Ejemplo n.º 3
0
///////////////////////////////////////////////////////////////////////////////////
/// 指定窓の画面をキャプチャして指定ファイルにPNG形式で保存する
void CaptureScreen(CWnd *pWnd, const std::wstring &szFilePath) {

    CRect rectClient;
    pWnd->GetClientRect( &rectClient );

    CClientDC dc(pWnd);

    CDC dc2;
    dc2.CreateCompatibleDC( &dc );

    CBitmap bitmap;
    bitmap.CreateCompatibleBitmap(&dc, rectClient.Width(), rectClient.Height() );

    auto pOldBitmap = dc2.SelectObject( &bitmap );

    dc2.BitBlt(0,0, rectClient.Width(), rectClient.Height(), &dc, 0, 0, SRCCOPY );

    int nWidthAdjust = rectClient.Width();
    if ( nWidthAdjust % 4 ) { nWidthAdjust += 4 - nWidthAdjust % 4;}

    std::vector<BYTE> bitdata( nWidthAdjust * rectClient.Height() * 3 );

    dc2.SelectObject( pOldBitmap );

    BITMAPINFO bitmapinfo;
    ZeroMemory(&bitmapinfo, sizeof(BITMAPINFO) );
    bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bitmapinfo.bmiHeader.biWidth = nWidthAdjust;
    bitmapinfo.bmiHeader.biHeight = rectClient.Height();
    bitmapinfo.bmiHeader.biPlanes = 1;
    bitmapinfo.bmiHeader.biBitCount = 24;
    bitmapinfo.bmiHeader.biCompression = BI_RGB;
    GetDIBits( dc2, bitmap, 0, rectClient.Height(), bitdata.data(), &bitmapinfo, DIB_RGB_COLORS );


    boost::gil::rgb8_image_t img( nWidthAdjust, rectClient.Height() );
    copy_pixels(boost::gil::interleaved_view(nWidthAdjust, rectClient.Height(), (const boost::gil::rgb8_pixel_t*)bitdata.data(), nWidthAdjust*3), view(img));
    png_write_view(CStringA(szFilePath.c_str()), boost::gil::flipped_up_down_view( const_view(img) ) );
}
Ejemplo n.º 4
0
inline void png_write_view(const std::string& filename,const View& view) {
    png_write_view(filename.c_str(),view);
}