コード例 #1
0
static inline void
ImportSurface(WritableImageBuffer<PixelTraits> &buffer,
              const UncompressedImage &uncompressed)
{
  buffer.Allocate(uncompressed.GetWidth(), uncompressed.GetHeight());

  switch (uncompressed.GetFormat()) {
  case UncompressedImage::Format::INVALID:
    assert(false);
    gcc_unreachable();

  case UncompressedImage::Format::RGB:
  case UncompressedImage::Format::RGBA:
    ConvertFromRGB<PixelTraits>(buffer,
                                (const uint8_t *)uncompressed.GetData(),
                                uncompressed.GetPitch());
    break;

  case UncompressedImage::Format::GRAY:
    ConvertFromGray<PixelTraits>(buffer,
                                 (const uint8_t *)uncompressed.GetData(),
                                 uncompressed.GetPitch());
    break;
  }
}
コード例 #2
0
ファイル: UnitSymbol.cpp プロジェクト: Adrien81/XCSoar
void
UnitSymbol::Load(ResourceId id)
{
#ifdef USE_MEMORY_CANVAS
  assert(IsScreenInitialized());
  assert(buffer.data == nullptr);

  ResourceLoader::Data data = ResourceLoader::Load(id);
  assert(!data.IsNull());

  const UncompressedImage uncompressed = LoadPNG(data.data, data.size);
  assert(uncompressed.GetFormat() == UncompressedImage::Format::GRAY);

  const size_t size = uncompressed.GetPitch() * uncompressed.GetHeight();
  buffer.data = new Luminosity8[size];
  memcpy(buffer.data, uncompressed.GetData(), size);

  buffer.pitch = uncompressed.GetPitch();
  buffer.width = uncompressed.GetWidth();
  buffer.height = uncompressed.GetHeight();
#else
  bitmap.Load(id, Bitmap::Type::MONO);
  size = bitmap.GetSize();
#endif
}
コード例 #3
0
ファイル: Bitmap.cpp プロジェクト: DRIZO/xcsoar
bool
Bitmap::Load(const UncompressedImage &uncompressed, gcc_unused Type type)
{
  delete texture;
  texture = type == Type::MONO
    ? ImportAlphaTexture(uncompressed)
    : ImportTexture(uncompressed);
  if (texture == nullptr)
    return false;

  if (interpolation)
    texture->EnableInterpolation();

  size = { uncompressed.GetWidth(), uncompressed.GetHeight() };
  return true;
}
コード例 #4
0
ファイル: UnitSymbol.cpp プロジェクト: MindMil/XCSoar
void
UnitSymbol::Load(unsigned id)
{
  assert(IsScreenInitialized());
  assert(buffer.data == nullptr);

  ResourceLoader::Data data = ResourceLoader::Load(id);
  assert(data.first != nullptr);

  const UncompressedImage uncompressed = LoadPNG(data.first, data.second);
  assert(uncompressed.GetFormat() == UncompressedImage::Format::GRAY);

  const size_t size = uncompressed.GetPitch() * uncompressed.GetHeight();
  buffer.data = new Luminosity8[size];
  memcpy(buffer.data, uncompressed.GetData(), size);

  buffer.pitch = uncompressed.GetPitch();
  buffer.width = uncompressed.GetWidth();
  buffer.height = uncompressed.GetHeight();
}