Sfoglia il codice sorgente

image: revert GDI+ animated GIF tests; we’ll try something else.

undefined
Sam Hocevar 10 anni fa
parent
commit
90a60ba446
4 ha cambiato i file con 0 aggiunte e 135 eliminazioni
  1. +0
    -120
      src/image/codec/gdiplus-image.cpp
  2. +0
    -6
      src/image/image-private.h
  3. +0
    -8
      src/image/image.cpp
  4. +0
    -1
      src/lol/image/image.h

+ 0
- 120
src/image/codec/gdiplus-image.cpp Vedi File

@@ -38,7 +38,6 @@ class GdiPlusImageCodec : public ImageCodec
public:
virtual bool Load(Image *image, char const *path);
virtual bool Save(Image *image, char const *path);
virtual bool Save(array<Image *> const &images, char const *path);
};

DECLARE_IMAGE_CODEC(GdiPlusImageCodec, 100)
@@ -217,125 +216,6 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)
return true;
}

bool GdiPlusImageCodec::Save(array<Image *> const &images, char const *path)
{
ULONG_PTR token;
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartup(&token, &input, nullptr);

wchar_t const *fmt = L"image/gif";

unsigned int num = 0, encoder_size = 0;
Gdiplus::GetImageEncodersSize(&num, &encoder_size);
if (num == 0)
{
Log::Error("no GDI+ image encoders found\n");
return false;
}
Gdiplus::ImageCodecInfo *codecs
= (Gdiplus::ImageCodecInfo *)new uint8_t[encoder_size];
Gdiplus::GetImageEncoders(num, encoder_size, codecs);
CLSID clsid;
for (unsigned int i = 0; i < num; i++)
{
if (wcscmp(codecs[i].MimeType, fmt) == 0)
{
clsid = codecs[i].Clsid;
break;
}
}

// FIXME: clsid can be uninitialised

size_t len;
len = mbstowcs(nullptr, path, 0);
wchar_t *wpath = new wchar_t[len + 1];
if (mbstowcs(wpath, path, len + 1) == (size_t)-1)
{
Log::Error("could not convert GDI+ filename '%s' to widechar\n", path);
delete[] wpath;
delete[] codecs;
return false;
}

Gdiplus::Image *root_image = nullptr;

Gdiplus::Bitmap *tmp = new Gdiplus::Bitmap(1, 1, PixelFormat32bppARGB);
unsigned int param_count = tmp->GetEncoderParameterListSize(&clsid);
printf("%d parameters\n", param_count);

Gdiplus::EncoderParameters *params = (Gdiplus::EncoderParameters *)malloc(sizeof(params->Count) + param_count * sizeof(params->Parameter[0]));
tmp->GetEncoderParameterList(&clsid, param_count, params);
for (int i = 0; i < param_count; ++i)
{
printf("parameter %d has type %d and GUID %08x-%04x-%04x\n", i, params->Parameter[i].Type, params->Parameter[i].Guid.Data1, params->Parameter[i].Guid.Data2, params->Parameter[i].Guid.Data3);
//params->Parameter[i];
}
delete params;
delete tmp;

for (int i = 0; i < images.Count(); ++i)
{
ivec2 size = images[i]->GetSize();

Gdiplus::Bitmap *b = new Gdiplus::Bitmap(size.x, size.y,
PixelFormat32bppARGB);
Gdiplus::BitmapData bdata;
Gdiplus::Rect rect(0, 0, size.x, size.y);

if (b->LockBits(&rect, (unsigned int)Gdiplus::ImageLockModeWrite,
PixelFormat32bppARGB, &bdata) != Gdiplus::Ok)
{
Log::Error("could not lock GDI+ image bits\n");
delete b;
delete[] wpath;
delete[] codecs;
return false;
}

u8vec4 *psrc = images[i]->Lock<PixelFormat::RGBA_8>();
u8vec4 *psrc0 = psrc;
u8vec4 *pdst = static_cast<u8vec4 *>(bdata.Scan0);
for (int y = 0; y < size.y; y++)
for (int x = 0; x < size.x; x++)
*pdst++ = (*psrc++).bgra;
images[i]->Unlock(psrc0);
b->UnlockBits(&bdata);

Gdiplus::Status ret;
if (i == 0)
{
root_image = b;
b = nullptr;
ret = root_image->Save(wpath, &clsid, nullptr);
}
else
{
Gdiplus::EncoderParameters eparm;
eparm.Count = 0;
ret = root_image->SaveAdd(b, &eparm);
}

if (ret != Gdiplus::Ok)
{
Log::Error("could not save GDI+ image '%s'\n", path);
delete[] wpath;
delete[] codecs;
delete root_image;
delete b;
return false;
}

delete b;
}

delete[] wpath;
delete[] codecs;
delete root_image;

return true;
}

} /* namespace lol */

#endif /* defined USE_GDIPLUS */


+ 0
- 6
src/image/image-private.h Vedi File

@@ -72,12 +72,6 @@ public:
virtual bool Load(Image *image, char const *path) = 0;
virtual bool Save(Image *image, char const *path) = 0;

/* TODO: For animated GIFs. Maybe move this to a Movie object instead? */
virtual bool Save(array<Image *> const &images, char const *path)
{
return false;
}

/* TODO: this should become more fine-grained */
int m_priority;
};


+ 0
- 8
src/image/image.cpp Vedi File

@@ -144,14 +144,6 @@ bool Image::Save(char const *path)
return false;
}

bool Image::Save(array<Image *> const &images, char const *path)
{
for (auto codec : g_image_loader.m_codecs)
if (codec->Save(images, path))
return true;
return false;
}

ivec2 Image::GetSize() const
{
return m_data->m_size;


+ 0
- 1
src/lol/image/image.h Vedi File

@@ -72,7 +72,6 @@ public:

bool Load(char const *path);
bool Save(char const *path);
static bool Save(array<Image *> const &images, char const *path);

/* Low level access */
ivec2 GetSize() const;


Caricamento…
Annulla
Salva