Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to blit bitmap? #1

Open
sailfish009 opened this issue May 12, 2016 · 5 comments
Open

how to blit bitmap? #1

sailfish009 opened this issue May 12, 2016 · 5 comments

Comments

@sailfish009
Copy link

Hi, i am testing bitmap display with basicbitmap,

but, it didn't displayed on window, how to do it properly?

https://github.com/sailfish009/StreamPlayer/blob/master/Frame.cpp

BasicBitmap bitmap = BasicBitmap(width_, height_,BasicBitmap::A8R8G8B8, pixelsPtr_,2048);
bitmap.Blit(rc.left, rc.top, &bitmap, rc.right - rc.left, rc.bottom - rc.top, width_, height_);

@skywind3000
Copy link
Owner

skywind3000 commented May 12, 2016

you are blitting one bitmap onto itself.
use:
bitmap. SetDIBitsToDevice(hdc, 0, 0, width, height);
in windows instead

@sailfish009
Copy link
Author

it also didn't worked.


BasicBitmap bitmap = BasicBitmap(width_, height_,BasicBitmap::A8R8G8B8, pixelsPtr_, 2048);
  PAINTSTRUCT ps;
  HDC hdc = ::BeginPaint(window, &ps);
  assert(hdc != nullptr);
  ::SetStretchBltMode(hdc, HALFTONE);
  bitmap.SetDIBitsToDevice(hdc, 0, 0, width_, height_, 0, 0);
  bitmap.Blit(rc.left, rc.top, &bitmap, rc.right - rc.left, rc.bottom - rc.top, width_, height_);
  ::EndPaint(window, &ps);

@skywind3000
Copy link
Owner

bitmap.SetDIBitsToDevice(hdc, 0, 0, width_, height_, width_, height_);

@sailfish009
Copy link
Author

sailfish009 commented May 13, 2016

nope, it didn't worked, too.
i had tried following codes, it didn't.

  BasicBitmap bitmap = BasicBitmap(width_, height_, BasicBitmap::R8G8B8, pixelsPtr_, width_ << 1);
  BasicBitmap bitmap = BasicBitmap(width_, height_, BasicBitmap::R8G8B8, pixelsPtr_, 512);
  BasicBitmap bitmap = BasicBitmap(width_, height_,BasicBitmap::A8R8G8B8, pixelsPtr_, 1024);
  BasicBitmap bitmap = BasicBitmap(width_, height_,BasicBitmap::R8G8B8, pixelsPtr_,2048);
  BasicBitmap bitmap = BasicBitmap(width_, height_, BasicBitmap::R8G8B8, pixelsPtr_, pitch_); //pitch_ = lineSize + padding;
BasicBitmap bitmap = BasicBitmap(width_, height_, BasicBitmap::R8G8B8, pixelsPtr_, width_ >> 1);

however, for sure, checked that legacy code (StretchDIBits) works fine.

@sailfish009
Copy link
Author

Direct2D, Direct3D, Win32(StretchDIBits) all works fine,

But, Still BasicBitmap doesn't worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants