Exemplo n.º 1
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth)),
   buffer(new RawColor[corrected_width * height])
{
  assert(nWidth > 0);
  assert(nHeight > 0);

  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
  bi.bmiHeader.biWidth = corrected_width;
  bi.bmiHeader.biHeight = height;
  bi.bmiHeader.biPlanes = 1;
  bi.bmiHeader.biBitCount = 24;
  bi.bmiHeader.biCompression = BI_RGB;
  bi.bmiHeader.biSizeImage = 0;
  bi.bmiHeader.biXPelsPerMeter = 3780;
  bi.bmiHeader.biYPelsPerMeter = 3780;
  bi.bmiHeader.biClrUsed = 0;
  bi.bmiHeader.biClrImportant = 0;

  VOID *pvBits;
  HDC hDC = ::GetDC(nullptr);
  bitmap = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, nullptr, 0);
  ::ReleaseDC(nullptr, hDC);
  buffer = (RawColor *)pvBits;
}
Exemplo n.º 2
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight, const Color clr)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth))
{
  assert(nWidth > 0);
  assert(nHeight > 0);

#ifdef ENABLE_SDL
  Uint32 rmask, gmask, bmask, amask;

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
  rmask = 0x000000ff;
  gmask = 0x0000ff00;
  bmask = 0x00ff0000;
#else
  rmask = 0x00ff0000;
  gmask = 0x0000ff00;
  bmask = 0x000000ff;
#endif
  amask = 0x00000000;

  surface = ::SDL_CreateRGBSurface(SDL_SWSURFACE, corrected_width, height, 24,
                                   rmask, gmask, bmask, amask);
  assert(!SDL_MUSTLOCK(surface));

  buffer = (BGRColor *)surface->pixels;
#else /* !ENABLE_SDL */
  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
  bi.bmiHeader.biWidth = corrected_width;
  bi.bmiHeader.biHeight = height;
  bi.bmiHeader.biPlanes = 1;
  bi.bmiHeader.biBitCount = 24;
  bi.bmiHeader.biCompression = BI_RGB;
  bi.bmiHeader.biSizeImage = 0;
  bi.bmiHeader.biXPelsPerMeter = 3780;
  bi.bmiHeader.biYPelsPerMeter = 3780;
  bi.bmiHeader.biClrUsed = 0;
  bi.bmiHeader.biClrImportant = 0;

#if defined(_WIN32_WCE) && _WIN32_WCE < 0x0400
  /* StretchDIBits() is bugged on PPC2002, workaround follows */
  VOID *pvBits;
  HDC hDC = ::GetDC(NULL);
  bitmap = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
  ::ReleaseDC(NULL, hDC);
  buffer = (BGRColor *)pvBits;
#else
  buffer = new BGRColor[corrected_width * height];
#endif
#endif /* !ENABLE_SDL */

  std::fill(buffer, buffer + corrected_width * height,
            BGRColor(clr.blue(), clr.green(), clr.red()));
}
Exemplo n.º 3
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth)),
   buffer(new RawColor[corrected_width * height]),
   texture(new GLTexture(corrected_width, nHeight))
{
  assert(nWidth > 0);
  assert(nHeight > 0);

  texture->EnableInterpolation();

  AddSurfaceListener(*this);
}
Exemplo n.º 4
0
BOOL CSTScreenBuffer::CreateBitmap(int nWidth, int nHeight)
{
  LKASSERT(nWidth>0);
  LKASSERT(nHeight>0);
  
  if (m_hBitmap!=NULL) DeleteObject(m_hBitmap);
  
  m_nCorrectedWidth = CorrectedWidth(nWidth);
  m_nWidth = nWidth;
  m_nHeight = nHeight;
  
  DIBINFO  dibInfo;
  
  dibInfo.bmiHeader.biBitCount = 24;
  dibInfo.bmiHeader.biClrImportant = 0;
  dibInfo.bmiHeader.biClrUsed = 0;
  dibInfo.bmiHeader.biCompression = 0;
  dibInfo.bmiHeader.biHeight = m_nHeight;
  dibInfo.bmiHeader.biPlanes = 1;
  dibInfo.bmiHeader.biSize = 40;
  dibInfo.bmiHeader.biSizeImage = m_nCorrectedWidth*m_nHeight*3;
  dibInfo.bmiHeader.biWidth = m_nCorrectedWidth;
  dibInfo.bmiHeader.biXPelsPerMeter = 3780;
  dibInfo.bmiHeader.biYPelsPerMeter = 3780;
  dibInfo.bmiColors[0].rgbBlue = 0;
  dibInfo.bmiColors[0].rgbGreen = 0;
  dibInfo.bmiColors[0].rgbRed = 0;
  dibInfo.bmiColors[0].rgbReserved = 0;
  
  HDC hDC = ::GetDC(NULL);
  LKASSERT(hDC);
  BGRColor **pBuffer = &m_pBuffer;
  m_hBitmap = CreateDIBSection(hDC, (const BITMAPINFO*)dibInfo, DIB_RGB_COLORS, (void**)pBuffer, NULL, 0);
  ::ReleaseDC(NULL, hDC);
  LKASSERT(m_hBitmap);
  LKASSERT(m_pBuffer);
  
  m_pBufferTmp = (BGRColor*)malloc(sizeof(BGRColor)*m_nHeight*m_nCorrectedWidth);
  LKASSERT(m_pBufferTmp);
  
  return TRUE;
}
Exemplo n.º 5
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth))
{
  assert(nWidth > 0);
  assert(nHeight > 0);

  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
  bi.bmiHeader.biWidth = corrected_width;
  bi.bmiHeader.biHeight = height;
  bi.bmiHeader.biPlanes = 1;
  bi.bmiHeader.biBitCount = 24;
  bi.bmiHeader.biCompression = BI_RGB;
  bi.bmiHeader.biSizeImage = 0;
  bi.bmiHeader.biXPelsPerMeter = 3780;
  bi.bmiHeader.biYPelsPerMeter = 3780;
  bi.bmiHeader.biClrUsed = 0;
  bi.bmiHeader.biClrImportant = 0;

#ifdef _WIN32_WCE
  /* configure 16 bit 5-5-5 on Windows CE */
  bi.bmiHeader.biBitCount = 16;
  bi.bmiHeader.biCompression = BI_BITFIELDS;
  bi.bmiHeader.biClrUsed = 3;
  LPVOID p = &bi.bmiColors[0];
  DWORD *q = (DWORD *)p;
  *q++ = 0x7c00; /* 5 bits red */
  *q++ = 0x03e0; /* 5 bits green */
  *q++ = 0x001f; /* 5 bits blue */
#endif

#if defined(_WIN32_WCE) && _WIN32_WCE < 0x0400
  /* StretchDIBits() is bugged on PPC2002, workaround follows */
  VOID *pvBits;
  HDC hDC = ::GetDC(nullptr);
  bitmap = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, nullptr, 0);
  ::ReleaseDC(nullptr, hDC);
  buffer = (BGRColor *)pvBits;
#else
  buffer = new BGRColor[corrected_width * height];
#endif
}
Exemplo n.º 6
0
BOOL CSTScreenBuffer::CreateBitmap(int nWidth, int nHeight)
{
  assert(nWidth>0);
  assert(nHeight>0);

  if (m_hBitmap.defined())
    m_hBitmap.reset();

  m_nCorrectedWidth = CorrectedWidth(nWidth);
  m_nWidth = nWidth;
  m_nHeight = nHeight;

  m_pBuffer = (BGRColor *)m_hBitmap.create(m_nCorrectedWidth, m_nHeight);
  assert(m_hBitmap.defined());
  assert(m_pBuffer);

  m_pBufferTmp = (BGRColor*)malloc(sizeof(BGRColor)*m_nHeight*m_nCorrectedWidth);

  return TRUE;
}
Exemplo n.º 7
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth))
#ifdef ENABLE_OPENGL
  , texture(CorrectedWidth(nWidth), nHeight)
#endif
{
  assert(nWidth > 0);
  assert(nHeight > 0);

#ifdef ENABLE_OPENGL
  buffer = new BGRColor[corrected_width * height];
#elif defined(ENABLE_SDL)
  Uint32 rmask, gmask, bmask, amask;
  int depth;

#ifdef ANDROID
  rmask = 0x0000f800;
  gmask = 0x000007e0;
  bmask = 0x0000001f;
  depth = 16;
#else
  rmask = 0x00ff0000;
  gmask = 0x0000ff00;
  bmask = 0x000000ff;
  depth = 32;
#endif
  amask = 0x00000000;

  assert(sizeof(BGRColor) * 8 == depth);

  surface = ::SDL_CreateRGBSurface(SDL_SWSURFACE, corrected_width, height,
                                   depth, rmask, gmask, bmask, amask);
  assert(!SDL_MUSTLOCK(surface));

  buffer = (BGRColor *)surface->pixels;
#else /* !ENABLE_SDL */
  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
  bi.bmiHeader.biWidth = corrected_width;
  bi.bmiHeader.biHeight = height;
  bi.bmiHeader.biPlanes = 1;
  bi.bmiHeader.biBitCount = 24;
  bi.bmiHeader.biCompression = BI_RGB;
  bi.bmiHeader.biSizeImage = 0;
  bi.bmiHeader.biXPelsPerMeter = 3780;
  bi.bmiHeader.biYPelsPerMeter = 3780;
  bi.bmiHeader.biClrUsed = 0;
  bi.bmiHeader.biClrImportant = 0;

#ifdef _WIN32_WCE
  /* configure 16 bit 5-5-5 on Windows CE */
  bi.bmiHeader.biBitCount = 16;
  bi.bmiHeader.biCompression = BI_BITFIELDS;
  bi.bmiHeader.biClrUsed = 3;
  LPVOID p = &bi.bmiColors[0];
  DWORD *q = (DWORD *)p;
  *q++ = 0x7c00; /* 5 bits red */
  *q++ = 0x03e0; /* 5 bits green */
  *q++ = 0x001f; /* 5 bits blue */
#endif

#if defined(_WIN32_WCE) && _WIN32_WCE < 0x0400
  /* StretchDIBits() is bugged on PPC2002, workaround follows */
  VOID *pvBits;
  HDC hDC = ::GetDC(NULL);
  bitmap = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
  ::ReleaseDC(NULL, hDC);
  buffer = (BGRColor *)pvBits;
#else
  buffer = new BGRColor[corrected_width * height];
#endif
#endif /* !ENABLE_SDL */
}
Exemplo n.º 8
0
RawBitmap::RawBitmap(unsigned nWidth, unsigned nHeight)
  :width(nWidth), height(nHeight),
   corrected_width(CorrectedWidth(nWidth)),
   buffer(new BGRColor[corrected_width * height])
{
}