static HRESULT WINAPI BmpFrameEncode_WritePixels(IWICBitmapFrameEncode *iface, UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels) { BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; WICRect rc; TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels); if (!This->initialized || !This->width || !This->height || !This->format) return WINCODEC_ERR_WRONGSTATE; hr = BmpFrameEncode_AllocateBits(This); if (FAILED(hr)) return hr; rc.X = 0; rc.Y = 0; rc.Width = This->width; rc.Height = lineCount; hr = copy_pixels(This->format->bpp, pbPixels, This->width, lineCount, cbStride, &rc, This->stride, This->stride*(This->height-This->lineswritten), This->bits + This->stride*This->lineswritten); if (SUCCEEDED(hr)) This->lineswritten += lineCount; return hr; }
void draw_ground_plane_estimator(const GroundPlaneEstimator &ground_plane_estimator, const AbstractVideoInput::input_image_view_t &input_view, const StereoCameraCalibration &stereo_calibration, boost::gil::rgb8_view_t &screen_view) { // copy right screen image --- copy_and_convert_pixels(input_view, screen_view); // draw v-disparity image in the right screen image -- GroundPlaneEstimator::v_disparity_const_view_t raw_v_disparity_const_view = ground_plane_estimator.get_raw_v_disparity_view(); boost::gil::rgb8_view_t screen_subview = boost::gil::subimage_view(screen_view, 0,0, raw_v_disparity_const_view.width(), raw_v_disparity_const_view.height()); copy_and_convert_pixels(raw_v_disparity_const_view, screen_subview); // copy v disparity into the blue channel - GroundPlaneEstimator::v_disparity_const_view_t v_disparity_const_view = ground_plane_estimator.get_v_disparity_view(); copy_pixels(v_disparity_const_view, boost::gil::kth_channel_view<0>(screen_subview)); draw_v_disparity_lines(ground_plane_estimator, stereo_calibration, screen_subview); return; } // end of StixelWorldGui::draw_ground_plane_estimator(...)
/** * Update the pixel data in the current tile. */ int tile_stream_update (int id, guchar *data) { if (! valid_stream_id (id)) return -1; copy_pixels (&(streams[id]->target_region), data); return 0; } // tile_stream_update
bool JPEG_render(JPEG* jpeg, int src_x, int src_y, void* dst, int dst_w, int dst_h, int dst_x, int dst_y, int width, int height, bool fill_blank, int default_color) { return copy_pixels(jpeg->buffer, jpeg->width, jpeg->height, src_x, src_y, dst, dst_w, dst_h, dst_x, dst_y, width, height, fill_blank, default_color); }
bool PNG_render(PNG* png, int src_x, int src_y, void* dst, int dst_w, int dst_h, int dst_x, int dst_y, int width, int height, bool fill_blank, int default_color) { return copy_pixels(png->buffer, png->width, png->height, src_x, src_y, dst, dst_w, dst_h, dst_x, dst_y, width, height, fill_blank, default_color); }
static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { BitmapImpl *This = impl_from_IWICBitmap(iface); TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); return copy_pixels(This->bpp, This->data, This->width, This->height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); }
static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { PngDecoder *This = impl_from_frame(iface); TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); return copy_pixels(This->bpp, This->image_bits, This->width, This->height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); }
static HRESULT WINAPI GifFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { GifFrameDecode *This = (GifFrameDecode*)iface; TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); if (This->frame->ImageDesc.Interlace) { return copy_interlaced_pixels(This->frame->RasterBits, This->frame->ImageDesc.Width, This->frame->ImageDesc.Height, This->frame->ImageDesc.Width, prc, cbStride, cbBufferSize, pbBuffer); } else { return copy_pixels(8, This->frame->RasterBits, This->frame->ImageDesc.Width, This->frame->ImageDesc.Height, This->frame->ImageDesc.Width, prc, cbStride, cbBufferSize, pbBuffer); } }
/** * Advance to the next tile. Returns true if it succeeds and * false otherwise. */ gboolean tile_stream_advance (int id) { // Sanity checks if (! valid_stream_id (id)) return 0; // Advance the iterator. This has the side effect of changing // streams[id]->source_region and streams[id]->target_region. streams[id]->iterator = gimp_pixel_rgns_process (streams[id]->iterator); // Copy pixels over in case the user doesn't change them if (streams[id]->iterator != NULL) { copy_pixels (&(streams[id]->target_region), streams[id]->source_region.data); } // if we're not at the end // Did we succeed? return (streams[id]->iterator != NULL); } // tile_stream_advance
static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { BmpFrameDecode *This = (BmpFrameDecode*)iface; HRESULT hr; UINT width, height; TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); if (!This->imagedata) { hr = This->read_data_func(This); if (FAILED(hr)) return hr; } hr = BmpFrameDecode_GetSize(iface, &width, &height); if (FAILED(hr)) return hr; return copy_pixels(This->bitsperpixel, This->imagedatastart, width, height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); }
/////////////////////////////////////////////////////////////////////////////////// /// 指定窓の画面をキャプチャして指定ファイルに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) ) ); }
static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface); HRESULT hr=S_OK; UINT width, height; TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); EnterCriticalSection(&This->lock); if (!This->imagedata) { hr = This->read_data_func(This); } LeaveCriticalSection(&This->lock); if (FAILED(hr)) return hr; hr = BmpFrameDecode_GetSize(iface, &width, &height); if (FAILED(hr)) return hr; return copy_pixels(This->bitsperpixel, This->imagedatastart, width, height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); }
bool ImageBuf::write (ImageOutput *out, ProgressCallback progress_callback, void *progress_callback_data) const { stride_t as = AutoStride; bool ok = true; if (m_localpixels) { ok = out->write_image (m_spec.format, &m_pixels[0], as, as, as, progress_callback, progress_callback_data); } else { std::vector<char> tmp (m_spec.image_bytes()); copy_pixels (xbegin(), xend(), ybegin(), yend(), m_spec.format, &tmp[0]); ok = out->write_image (m_spec.format, &tmp[0], as, as, as, progress_callback, progress_callback_data); // FIXME -- not good for huge images. Instead, we should read // little bits at a time (scanline or tile blocks). } if (! ok) m_err = out->geterror (); return ok; }
int evdi_painter_grabpix_ioctl(struct drm_device *drm_dev, void *data, __always_unused struct drm_file *file) { struct evdi_device *evdi = drm_dev->dev_private; struct evdi_painter *painter = evdi->painter; struct drm_evdi_grabpix *cmd = data; struct drm_framebuffer *fb = NULL; struct evdi_framebuffer *efb = NULL; struct evdi_cursor *cursor_copy = NULL; int err = 0; EVDI_CHECKPT(); if (!painter) return -ENODEV; mutex_lock(&drm_dev->struct_mutex); if (evdi_cursor_alloc(&cursor_copy) == 0) evdi_cursor_copy(cursor_copy, evdi->cursor); mutex_unlock(&drm_dev->struct_mutex); painter_lock(painter); efb = painter->scanout_fb; if (!efb) { EVDI_ERROR("Scanout buffer not set\n"); err = -EAGAIN; goto unlock; } if (painter->was_update_requested) { EVDI_WARN("(dev=%d) Update ready not sent,", evdi->dev_index); EVDI_WARN(" but pixels are grabbed.\n"); } fb = &efb->base; if (!efb->obj->vmapping) { if (evdi_gem_vmap(efb->obj) == -ENOMEM) { EVDI_ERROR("Failed to map scanout buffer\n"); err = -EFAULT; goto unlock; } if (!efb->obj->vmapping) { EVDI_ERROR("Failed to map scanout buffer\n"); err = -EFAULT; goto unlock; } } if (cmd->buf_width != fb->width || cmd->buf_height != fb->height) { EVDI_ERROR("Invalid buffer dimension\n"); err = -EINVAL; goto unlock; } if (cmd->num_rects < 1) { EVDI_ERROR("No space for clip rects\n"); err = -EINVAL; goto unlock; } if (cmd->mode == EVDI_GRABPIX_MODE_DIRTY) { if (painter->num_dirts < 0) { err = -EAGAIN; goto unlock; } merge_dirty_rects(&painter->dirty_rects[0], &painter->num_dirts); if (painter->num_dirts > cmd->num_rects) collapse_dirty_rects(&painter->dirty_rects[0], &painter->num_dirts); cmd->num_rects = painter->num_dirts; if (copy_to_user(cmd->rects, painter->dirty_rects, cmd->num_rects * sizeof(cmd->rects[0]))) err = -EFAULT; else err = copy_pixels(efb, cmd->buffer, cmd->buf_byte_stride, painter->num_dirts, painter->dirty_rects, cmd->buf_width, cmd->buf_height, cursor_copy); painter->num_dirts = 0; } unlock: painter_unlock(painter); if (cursor_copy) evdi_cursor_free(cursor_copy); return err; }
static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { JpegDecoder *This = decoder_from_frame(iface); UINT bpp; UINT stride; UINT data_size; UINT max_row_needed; jmp_buf jmpbuf; WICRect rect; TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); if (!prc) { rect.X = 0; rect.Y = 0; rect.Width = This->cinfo.output_width; rect.Height = This->cinfo.output_height; prc = ▭ } else { if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->cinfo.output_width || prc->Y+prc->Height > This->cinfo.output_height) return E_INVALIDARG; } if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8; else if (This->cinfo.out_color_space == JCS_CMYK) bpp = 32; else bpp = 24; stride = bpp * This->cinfo.output_width; data_size = stride * This->cinfo.output_height; max_row_needed = prc->Y + prc->Height; if (max_row_needed > This->cinfo.output_height) return E_INVALIDARG; EnterCriticalSection(&This->lock); if (!This->image_data) { This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size); if (!This->image_data) { LeaveCriticalSection(&This->lock); return E_OUTOFMEMORY; } } This->cinfo.client_data = &jmpbuf; if (setjmp(jmpbuf)) { LeaveCriticalSection(&This->lock); return E_FAIL; } while (max_row_needed > This->cinfo.output_scanline) { UINT first_scanline = This->cinfo.output_scanline; UINT max_rows; JSAMPROW out_rows[4]; UINT i, j; JDIMENSION ret; max_rows = min(This->cinfo.output_height-first_scanline, 4); for (i=0; i<max_rows; i++) out_rows[i] = This->image_data + stride * (first_scanline+i); ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows); if (ret == 0) { ERR("read_scanlines failed\n"); LeaveCriticalSection(&This->lock); return E_FAIL; } if (bpp == 24) { /* libjpeg gives us RGB data and we want BGR, so byteswap the data */ for (i=first_scanline; i<This->cinfo.output_scanline; i++) { BYTE *pixel = This->image_data + stride * i; for (j=0; j<This->cinfo.output_width; j++) { BYTE red=pixel[0]; BYTE blue=pixel[2]; pixel[0]=blue; pixel[2]=red; pixel+=3; } } } if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker) /* Adobe JPEG's have inverted CMYK data. */ for (i=0; i<data_size; i++) This->image_data[i] ^= 0xff; } LeaveCriticalSection(&This->lock); return copy_pixels(bpp, This->image_data, This->cinfo.output_width, This->cinfo.output_height, stride, prc, cbStride, cbBufferSize, pbBuffer); }
void GCanvas::copy_pixels(const QRegion& region, RedDrawable* dest_dc, const PixmapHeader* pixmap) { copy_pixels(region, *dest_dc); }
/** * Get a read-write tile iterator for a portion of a drawable. * Returns -1 if it cannot create the iterator. */ int rectangle_new_tile_stream (int image, int drawable, int left, int top, int width, int height) { // Get an id to use for the iterator int id = next_iterator_id (); if (id < 0) { return id; } // Allocate space for information on the iterator TileStream *stream = (TileStream *) g_malloc0 (sizeof (TileStream)); if (stream == NULL) { return -1; } // Fill in the basic data stream->image = image; stream->drawable = drawable; stream->left = left; stream->top = top; stream->width = width; stream->height = height; stream->source = gimp_drawable_get (drawable); if (stream->source == NULL) { g_free (stream); return -1; } // if we could not get the drawable stream->target = gimp_drawable_get (drawable); if (stream->target == NULL) { g_free (stream->source); g_free (stream); return -1; } // Fill in the more advanced data gimp_pixel_rgn_init (&(stream->source_region), stream->source, left, top, width, height, FALSE, FALSE); gimp_pixel_rgn_init (&(stream->target_region), stream->target, left, top, width, height, TRUE, TRUE); stream->iterator = gimp_pixel_rgns_register (2, &(stream->source_region), &(stream->target_region)); // Copy pixels over in case the user doesn't change them copy_pixels (&(stream->target_region), stream->source_region.data); // HACK FOR TESTING invert_pixels (&(stream->target_region)); // And we're done streams[id] = stream; return id; } // rectangle_new_tile_stream
GIL_FORCEINLINE void apply_compatible(const View1& src, const View2& dst) const { copy_pixels(src,dst); }
void BitmapUtilsT<PFsrc,PFdst>::CopyBlit(uint8_t* dst_pixels, const uint8_t* src_pixels, int n) { copy_pixels(dst_pixels, src_pixels, n); }
HRESULT WINAPI D3DXLoadVolumeFromMemory(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_memory, D3DFORMAT src_format, UINT src_row_pitch, UINT src_slice_pitch, const PALETTEENTRY *src_palette, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key) { HRESULT hr; D3DVOLUME_DESC desc; D3DLOCKED_BOX locked_box; struct volume dst_size, src_size; const struct pixel_format_desc *src_format_desc, *dst_format_desc; TRACE("(%p, %p, %p, %p, %#x, %u, %u, %p, %p, %x, %x)\n", dst_volume, dst_palette, dst_box, src_memory, src_format, src_row_pitch, src_slice_pitch, src_palette, src_box, filter, color_key); if (!dst_volume || !src_memory || !src_box) return D3DERR_INVALIDCALL; if (src_format == D3DFMT_UNKNOWN || src_box->Left >= src_box->Right || src_box->Top >= src_box->Bottom || src_box->Front >= src_box->Back) return E_FAIL; if (filter == D3DX_DEFAULT) filter = D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER; IDirect3DVolume9_GetDesc(dst_volume, &desc); src_size.width = src_box->Right - src_box->Left; src_size.height = src_box->Bottom - src_box->Top; src_size.depth = src_box->Back - src_box->Front; if (!dst_box) { dst_size.width = desc.Width; dst_size.height = desc.Height; dst_size.depth = desc.Depth; } else { if (dst_box->Left >= dst_box->Right || dst_box->Right > desc.Width) return D3DERR_INVALIDCALL; if (dst_box->Top >= dst_box->Bottom || dst_box->Bottom > desc.Height) return D3DERR_INVALIDCALL; if (dst_box->Front >= dst_box->Back || dst_box->Back > desc.Depth) return D3DERR_INVALIDCALL; dst_size.width = dst_box->Right - dst_box->Left; dst_size.height = dst_box->Bottom - dst_box->Top; dst_size.depth = dst_box->Back - dst_box->Front; } src_format_desc = get_format_info(src_format); if (src_format_desc->type == FORMAT_UNKNOWN) return E_NOTIMPL; dst_format_desc = get_format_info(desc.Format); if (dst_format_desc->type == FORMAT_UNKNOWN) return E_NOTIMPL; if (desc.Format == src_format && dst_size.width == src_size.width && dst_size.height == src_size.height && dst_size.depth == src_size.depth && color_key == 0) { const BYTE *src_addr; if (src_box->Left & (src_format_desc->block_width - 1) || src_box->Top & (src_format_desc->block_height - 1) || (src_box->Right & (src_format_desc->block_width - 1) && src_size.width != desc.Width) || (src_box->Bottom & (src_format_desc->block_height - 1) && src_size.height != desc.Height)) { FIXME("Source box (%u, %u, %u, %u) is misaligned\n", src_box->Left, src_box->Top, src_box->Right, src_box->Bottom); return E_NOTIMPL; } src_addr = src_memory; src_addr += src_box->Front * src_slice_pitch; src_addr += (src_box->Top / src_format_desc->block_height) * src_row_pitch; src_addr += (src_box->Left / src_format_desc->block_width) * src_format_desc->block_byte_count; hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0); if (FAILED(hr)) return hr; copy_pixels(src_addr, src_row_pitch, src_slice_pitch, locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc); IDirect3DVolume9_UnlockBox(dst_volume); } else { const BYTE *src_addr; if (((src_format_desc->type != FORMAT_ARGB) && (src_format_desc->type != FORMAT_INDEX)) || (dst_format_desc->type != FORMAT_ARGB)) { FIXME("Pixel format conversion is not implemented %#x -> %#x\n", src_format_desc->format, dst_format_desc->format); return E_NOTIMPL; } src_addr = src_memory; src_addr += src_box->Front * src_slice_pitch; src_addr += src_box->Top * src_row_pitch; src_addr += src_box->Left * src_format_desc->bytes_per_pixel; hr = IDirect3DVolume9_LockBox(dst_volume, &locked_box, dst_box, 0); if (FAILED(hr)) return hr; if ((filter & 0xf) == D3DX_FILTER_NONE) { convert_argb_pixels(src_memory, src_row_pitch, src_slice_pitch, &src_size, src_format_desc, locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key, src_palette); } else { if ((filter & 0xf) != D3DX_FILTER_POINT) FIXME("Unhandled filter %#x.\n", filter); point_filter_argb_pixels(src_addr, src_row_pitch, src_slice_pitch, &src_size, src_format_desc, locked_box.pBits, locked_box.RowPitch, locked_box.SlicePitch, &dst_size, dst_format_desc, color_key, src_palette); } IDirect3DVolume9_UnlockBox(dst_volume); } return D3D_OK; }
void BitmapUtilsT<PFsrc,PFdst>::FlipV(uint8_t*& pixels_up, uint8_t*& pixels_down, int n, uint8_t* tmp_buffer) { copy_pixels(tmp_buffer, pixels_down, n); copy_pixels(pixels_down, pixels_up, n); copy_pixels(pixels_up, tmp_buffer, n); }