YSTest: Image.cpp 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
Image.cpp
浏览该文件的文档.
1 /*
2 © 2013-2014 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "YSLib/Service/YModules.h"
29 #include "CHRLib/YModules.h"
30 #include YFM_YSLib_Adaptor_Image
31 #include <FreeImage.h>
32 #include YFM_YSLib_Service_YBlit
33 #include YFM_YSLib_Service_YGDI
34 #include YFM_CHRLib_CharacterProcessing // for CHRLib::ToASCII;
35
36 namespace YSLib
37 {
38
39 namespace Drawing
40 {
41
43 static_assert(int(SamplingFilter::Box) == FILTER_BOX && int(
44 SamplingFilter::Bicubic) == FILTER_BICUBIC && int(SamplingFilter::Bilinear)
45 == FILTER_BILINEAR && int(SamplingFilter::BSpline) == FILTER_BSPLINE && int(
46 SamplingFilter::CatmullRom) == FILTER_CATMULLROM && int(
47 SamplingFilter::Lanczos3) == FILTER_LANCZOS3, "Incompatible filter found.");
48
50 namespace
51 {
52
54 void DLL_CALLCONV
55 FI_OutputMessage(::FREE_IMAGE_FORMAT fif, const char* msg)
56 {
57 YTraceDe(Warning, "FreeImage failed, format = %d: %s.", int(fif), msg);
58
59 yunused(fif),
60 yunused(msg);
61 }
62
63 ::FreeImageIO u8_io{
64 [](void *buffer, unsigned size, unsigned nmemb, fi_handle h){
65 return unsigned(std::fread(buffer, std::size_t(size),
66 std::size_t(nmemb), static_cast<std::FILE*>(h)));
67 },
68 [](void *buffer, unsigned size, unsigned nmemb, fi_handle h){
69 return unsigned(std::fwrite(buffer, std::size_t(size),
70 std::size_t(nmemb), static_cast<std::FILE*>(h)));
71 },
72 [](::fi_handle h, long offset, int whence){
73 return std::fseek(static_cast<std::FILE*>(h), offset, whence);
74 },
75 [](::fi_handle h){
76 return std::ftell(static_cast<std::FILE*>(h));
77 }
78 };
79
81
82 ::FIBITMAP*
83 LoadImage(ImageFormat fmt, std::FILE* fp, ImageDecoderFlags flags) ynothrow
84 {
85 if(fp)
86 {
87 const auto bitmap(::FreeImage_LoadFromHandle(::FREE_IMAGE_FORMAT(fmt),
88 &u8_io, ::fi_handle(fp), int(flags)));
89
90 std::fclose(fp);
91 return bitmap;
92 }
93 return {};
94 }
95 ::FIBITMAP*
96 LoadImage(ImageFormat fmt, const char* filename, ImageDecoderFlags flags)
97 ynothrow
98 {
99 return LoadImage(fmt, ufopen(filename, "rb"), flags);
100 }
101 ::FIBITMAP*
102 LoadImage(ImageFormat fmt, const char16_t* filename, ImageDecoderFlags flags)
103 ynothrow
104 {
105 return LoadImage(fmt, ufopen(filename, u"rb"), flags);
106 }
107
108 bool
109 SaveImage(ImageFormat fmt, ::FIBITMAP* dib, std::FILE* fp,
110 ImageDecoderFlags flags) ynothrow
111 {
112 if(dib)
113 {
114 const bool res(::FreeImage_SaveToHandle(::FREE_IMAGE_FORMAT(fmt),
115 dib, &u8_io, ::fi_handle(fp), int(flags)));
116
117 std::fclose(fp);
118 return res;
119 }
120 return {};
121 }
122 bool
123 SaveImage(ImageFormat fmt, ::FIBITMAP* dib, const char* filename,
124 ImageDecoderFlags flags) ynothrow
125 {
126 return SaveImage(fmt, dib, ufopen(filename, "wb"), flags);
127 }
128 bool
129 SaveImage(ImageFormat fmt, ::FIBITMAP* dib, const char16_t* filename,
130 ImageDecoderFlags flags) ynothrow
131 {
132 return SaveImage(fmt, dib, ufopen(filename, u"wb"), flags);
133 }
135
137
138 ImageFormat
139 GetFileType(std::FILE* fp)
140 {
141 if(fp)
142 {
143 const auto
144 fif(::FreeImage_GetFileTypeFromHandle(&u8_io, ::fi_handle(fp)));
145
146 std::fclose(fp);
147 return ImageFormat(fif);
148 }
149 return ImageFormat::Unknown;
150 }
151 ImageFormat
152 GetFileType(const char* filename)
153 {
154 return GetFileType(ufopen(filename, "rb"));
155 }
156 ImageFormat
157 GetFileType(const char16_t* filename)
158 {
159 return GetFileType(ufopen(filename, u"rb"));
160 }
162
163 ImageFormat
164 GetFormatFromFilename(const char16_t* filename)
165 {
166 const auto len(std::char_traits<char16_t>::length(filename));
167 const auto p(make_unique<char[]>(len + 1));
168 const auto str(p.get());
169
170 for(size_t i{}; i < len; ++i)
171 str[i] = CHRLib::ToASCII(filename[i]);
172 str[len] = u'\0';
173 return ImageFormat(::FreeImage_GetFIFFromFilename(str));
174 }
175
176 ::FI_PluginRec&
177 LookupPlugin(::FREE_IMAGE_FORMAT fif)
178 {
179 if(auto p_node = ::FreeImageEx_GetPluginNodeFromFIF(fif))
180 {
181 if(const auto p_plugin = p_node->m_plugin)
182 return *p_plugin;
183 else
184 throw LoggedEvent("Invalid plugin node found.");
185 }
186 else
187 throw LoggedEvent("No proper plugin found.");
188 }
189
190
191 #if (YCL_PIXEL_FORMAT_XYZ555 & 0x00FFFFFF) == 0x00BBCCDD
192 # define YF_PixConvSpec \
193 16, FI16_555_RED_MASK, FI16_555_GREEN_MASK, FI16_555_BLUE_MASK
194 #elif (YCL_PIXEL_FORMAT_XYZ555 & 0x00FFFFFF) == 0x00DDCCBB
195 # define YF_PixConvSpec \
196 16, FI16_555_BLUE_MASK, FI16_555_GREEN_MASK, FI16_555_RED_MASK
197 //#elif (YCL_PIXEL_FORMAT_XYZ555 & 0x00FFFFFF) == 0x00DDCCBB
198 //#elif (YCL_PIXEL_FORMAT_XYZ888 & 0x00FFFFFF) == 0x00BBCCDD
199 #elif (YCL_PIXEL_FORMAT_XYZ888 & 0x00FFFFFF) == 0x00DDCCBB
200 # define YF_PixConvSpec \
201 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK
202 # if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
203 //# elif FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB
204 // TODO: Add support for different color orders.
205 # else
206 # error "No supported FreeImage pixel format found."
207 # endif
208 #else
209 # error "Unsupported pixel format found."
210 #endif
211
212 } // unnamed namespace;
213
214
215 ImageMemory::ImageMemory(const HBitmap& pixmap, ImageFormat fmt,
216 ImageDecoderFlags flags)
217 : buffer(), handle(), format(fmt)
218 {
219 if(fmt == ImageFormat::Unknown)
220 throw UnknownImageFormat("Unknown image format found when saving.");
221
222 const auto p_data(pixmap.GetDataPtr());
223
224 if(!p_data)
225 throw LoggedEvent("Source image is empty.");
226 handle = ::FreeImage_OpenMemory();
227 if(!::FreeImage_SaveToMemory(::FREE_IMAGE_FORMAT(format), p_data,
228 handle, int(flags)))
229 throw LoggedEvent("Saving image to memory failed.");
230 }
231 ImageMemory::ImageMemory(Buffer buf)
232 : ImageMemory(std::move(buf), ImageFormat::Unknown)
233 {
234 format = ImageCodec::DetectFormat(handle, buffer.size());
235 }
236 ImageMemory::ImageMemory(Buffer buf, ImageFormat fmt)
237 : buffer([&]{
238 if(buf.empty())
239 throw LoggedEvent("Null buffer found.");
240 return std::move(buf);
241 }()), handle(::FreeImage_OpenMemory(static_cast<byte*>(buffer.data()),
242 static_cast< ::DWORD>(buffer.size()))), format(fmt)
243 {
244 if(!handle)
245 throw LoggedEvent("Opening image memory failed.");
246 }
247 ImageMemory::~ImageMemory()
248 {
249 if(!buffer.empty())
250 ::FreeImage_CloseMemory(handle);
251 }
252
253
254 HBitmap::HBitmap(const Size& s, BitPerPixel bpp)
255 : bitmap(::FreeImage_Allocate(s.Width, s.Height, bpp, 0, 0, 0))
256 {
257 if(!bitmap)
258 throw BadImageAlloc();
259 }
260 HBitmap::HBitmap(BitmapPtr src, const Size& s, size_t pitch_delta)
261 : bitmap([&]{
262 YAssertNonnull(src);
263 return ::FreeImage_ConvertFromRawBits(reinterpret_cast<byte*>(src),
264 s.Width, s.Height, s.Width * sizeof(PixelType) + pitch_delta,
265 YF_PixConvSpec, true);
266 }())
267 {
268 if(!bitmap)
269 throw LoggedEvent("Converting compact pixmap failed.");
270 }
271 HBitmap::HBitmap(const CompactPixmap& buf)
272 : HBitmap(buf.GetBufferPtr(), buf.GetSize())
273 {}
274 HBitmap::HBitmap(const char* filename, ImageDecoderFlags flags)
275 : HBitmap(filename, ImageCodec::DetectFormat(filename), flags)
276 {}
277 HBitmap::HBitmap(const char* filename, ImageFormat fmt, ImageDecoderFlags flags)
278 : bitmap(LoadImage(fmt, filename, flags))
279 {
280 if(!bitmap)
281 throw LoggedEvent("Loading image failed.");
282 }
283 HBitmap::HBitmap(const char16_t* filename, ImageDecoderFlags flags)
284 : HBitmap(filename, ImageCodec::DetectFormat(filename), flags)
285 {}
286 HBitmap::HBitmap(const char16_t* filename, ImageFormat fmt,
287 ImageDecoderFlags flags)
288 : bitmap(LoadImage(fmt, filename, flags))
289 {
290 if(!bitmap)
291 throw LoggedEvent("Loading image failed.");
292 }
293 HBitmap::HBitmap(const ImageMemory& mem, ImageDecoderFlags flags)
294 : bitmap(::FreeImage_LoadFromMemory(::FREE_IMAGE_FORMAT(mem.GetFormat()),
295 mem.GetNativeHandle(), int(flags)))
296 {
297 if(!bitmap)
298 throw LoggedEvent("Loading image failed.");
299 }
300 HBitmap::HBitmap(const HBitmap& pixmap, BitPerPixel bpp)
301 : bitmap([](::FIBITMAP* p_bmp, BitPerPixel bpp){
302 switch(bpp)
303 {
304 case 32:
305 return FreeImage_ConvertTo32Bits(p_bmp);
306 case 24:
307 return FreeImage_ConvertTo24Bits(p_bmp);
308 case 16:
309 return FreeImage_ConvertTo16Bits555(p_bmp);
310 case 8:
311 return FreeImage_ConvertTo8Bits(p_bmp);
312 case 4:
313 return FreeImage_ConvertTo4Bits(p_bmp);
314 default:
315 throw UnsupportedImageFormat("Unsupported bit for pixel found.");
316 }
317 }(pixmap.bitmap, bpp))
318 {
319 if(!bitmap)
320 throw LoggedEvent("Converting bitmap failed.");
321 }
322 HBitmap::HBitmap(const HBitmap& pixmap, const Size& s, SamplingFilter sf)
323 : bitmap(::FreeImage_Rescale(pixmap.bitmap, s.Width, s.Height,
324 ::FREE_IMAGE_FILTER(sf)))
325 {
326 if(!bitmap)
327 throw LoggedEvent("Rescaling image failed.");
328 }
329 HBitmap::HBitmap(const HBitmap& pixmap)
330 : bitmap(::FreeImage_Clone(pixmap.bitmap))
331 {
332 if(!bitmap)
333 throw BadImageAlloc();
334 }
335 HBitmap::HBitmap(HBitmap&& pixmap) ynothrow
336 : bitmap(pixmap.bitmap)
337 {
338 pixmap.bitmap = {};
339 }
340 HBitmap::~HBitmap()
341 {
342 ::FreeImage_Unload(bitmap);
343 }
344
345 byte*
346 HBitmap::operator[](size_t idx) const ynothrow
347 {
348 YAssertNonnull(bitmap);
349 YAssert(idx < GetHeight(), "Index out of range.");
350 return ::FreeImage_GetScanLine(bitmap, idx);
351 }
352
353 HBitmap::operator CompactPixmap() const
354 {
355 const Size& s(GetSize());
356 auto pixels(make_unique<PixelType[]>(GetAreaOf(s)));
357
358 ::FreeImage_ConvertToRawBits(reinterpret_cast<byte*>(&pixels[0]),
359 GetDataPtr(), s.Width * sizeof(PixelType), YF_PixConvSpec, true);
360 return CompactPixmap(std::move(pixels), s);
361 }
362
363 BitPerPixel
364 HBitmap::GetBPP() const ynothrow
365 {
366 return ::FreeImage_GetBPP(bitmap);
367 }
368 SDst
369 HBitmap::GetHeight() const ynothrow
370 {
371 return ::FreeImage_GetHeight(bitmap);
372 }
373 SDst
374 HBitmap::GetPitch() const ynothrow
375 {
376 return ::FreeImage_GetPitch(bitmap);
377 }
378 byte*
379 HBitmap::GetPixels() const ynothrow
380 {
381 return ::FreeImage_GetBits(bitmap);
382 }
383 SDst
384 HBitmap::GetWidth() const ynothrow
385 {
386 return ::FreeImage_GetWidth(bitmap);
387 }
388
389 void
390 HBitmap::Rescale(const Size& s, SamplingFilter sf)
391 {
392 *this = HBitmap(*this, s, sf);
393 }
394
395 bool
396 HBitmap::SaveTo(const char* filename, ImageFormat fmt, ImageDecoderFlags flags)
397 const ynothrow
398 {
399 return SaveImage(fmt, GetDataPtr(), filename, flags);
400 }
401 bool
402 HBitmap::SaveTo(const char16_t* filename, ImageFormat fmt,
403 ImageDecoderFlags flags) const ynothrow
404 {
405 return SaveImage(fmt, GetDataPtr(), filename, flags);
406 }
407
408
409 class MultiBitmapData final : private noncopyable
410 {
411 private:
412 bool read;
413 ::fi_handle handle;
414 int load_flags;
415 std::reference_wrapper<::FreeImageIO> io_ref;
416 std::reference_wrapper<::FI_PluginRec> plugin_ref;
417 size_t page_count = 0;
418 void* data = {};
419
420 public:
421 MultiBitmapData(::fi_handle, int, ::FI_PluginRec&, ::FreeImageIO& = u8_io,
422 bool = true) ynothrow;
423 MultiBitmapData(ImageFormat, std::FILE&, int = 0, ::FreeImageIO& = u8_io,
424 bool = true) ynothrow;
426 ~MultiBitmapData();
427
428 DefPred(const ynothrow, OpenForRead, read)
429
430 DefGetter(const ynothrow, size_t, PageCount, page_count)
431
432 ::FIBITMAP*
433 LockPage(size_t = 0) const ynothrow;
434 };
435
436 MultiBitmapData::MultiBitmapData(::fi_handle h, int flags,
437 ::FI_PluginRec& plugin, ::FreeImageIO& io, bool open_for_reading) ynothrow
438 : read(open_for_reading), handle(h), load_flags(flags), io_ref(io),
439 plugin_ref(plugin)
440 {
441 io.seek_proc(handle, 0, SEEK_SET);
442 if(const auto open = plugin.open_proc)
443 {
444 data = open(&io_ref.get(), handle, open_for_reading);
445 if(const auto proc = plugin_ref.get().pagecount_proc)
446 page_count = proc(&io_ref.get(), handle, data);
447 else
448 page_count = 1;
449 }
450 }
451 MultiBitmapData::MultiBitmapData(ImageFormat fmt, std::FILE& f, int flags,
452 ::FreeImageIO& io, bool open_for_reading) ynothrow
453 : MultiBitmapData(::fi_handle(&f), flags,
454 LookupPlugin(::FREE_IMAGE_FORMAT(fmt)), io, open_for_reading)
455 {}
456 MultiBitmapData::~MultiBitmapData()
457 {
458 if(const auto close = plugin_ref.get().close_proc)
459 close(&io_ref.get(), handle, data);
460 }
461
462 ::FIBITMAP*
463 MultiBitmapData::LockPage(size_t index) const ynothrow
464 {
465 YAssert(index < page_count, "Invalid page index found.");
466 if(const auto load = plugin_ref.get().load_proc)
467 return load(&io_ref.get(), handle, int(index), load_flags, data);
468 return {};
469 }
470
471
473 namespace
474 {
475
477
478 MultiBitmapData*
479 LoadImagePages(ImageFormat fmt, std::FILE* fp, ImageDecoderFlags flags) ynothrow
480 {
481 if(fp)
482 try
483 {
484 return new MultiBitmapData(fmt, *fp, int(flags));
485 }
486 catch(std::exception&)
487 {}
488 return {};
489 }
490 MultiBitmapData*
491 LoadImagePages(ImageFormat fmt, const char* filename, ImageDecoderFlags flags)
492 ynothrow
493 {
494 return LoadImagePages(fmt, ufopen(filename, "rb"), flags);
495 }
496 MultiBitmapData*
497 LoadImagePages(ImageFormat fmt, const char16_t* filename,
498 ImageDecoderFlags flags) ynothrow
499 {
500 return LoadImagePages(fmt, ufopen(filename, u"rb"), flags);
501 }
503
504 } // unnamed namespace;
505
506
507 bool
508 operator==(const HMultiBitmap::iterator& x, const HMultiBitmap::iterator& y)
509 ynothrow
510 {
511 return x.p_bitmaps == y.p_bitmaps && (!x.p_bitmaps || x.index == y.index);
512 }
513
514 HMultiBitmap::HMultiBitmap(const char* filename, ImageDecoderFlags flags)
515 : HMultiBitmap(filename, ImageCodec::DetectFormat(filename), flags)
516 {}
517 HMultiBitmap::HMultiBitmap(const char* filename, ImageFormat fmt,
518 ImageDecoderFlags flags)
519 : pages(LoadImagePages(fmt, filename, flags))
520 {
521 if(!pages)
522 throw LoggedEvent("Loading image pages failed.");
523 }
524 HMultiBitmap::HMultiBitmap(const char16_t* filename, ImageDecoderFlags flags)
525 : HMultiBitmap(filename, ImageCodec::DetectFormat(filename), flags)
526 {}
527 HMultiBitmap::HMultiBitmap(const char16_t* filename, ImageFormat fmt,
528 ImageDecoderFlags flags)
529 : pages(LoadImagePages(fmt, filename, flags))
530 {
531 if(!pages)
532 throw LoggedEvent("Loading image pages failed.");
533 }
534
535 size_t
536 HMultiBitmap::GetPageCount() const ynothrow
537 {
538 return pages ? pages->GetPageCount() : 0;
539 }
540
541 HBitmap
542 HMultiBitmap::Lock(size_t i) const
543 {
544 return pages ? pages->LockPage(i) : nullptr;
545 }
546
547
548 ImageCodec::ImageCodec()
549 {
550 // XXX: Thread safety of errno.
551 const auto old_errno(errno);
552
553 ::FreeImage_Initialise(false);
554 ::FreeImage_SetOutputMessageStdCall(FI_OutputMessage);
555 errno = old_errno;
556 }
557 ImageCodec::~ImageCodec()
558 {
559 ::FreeImage_DeInitialise();
560 }
561
562 ImageFormat
563 ImageCodec::DetectFormat(ImageMemory::NativeHandle handle, size_t size)
564 {
565 return ImageFormat(::FreeImage_GetFileTypeFromMemory(handle, size));
566 }
567 ImageFormat
568 ImageCodec::DetectFormat(const char* filename)
569 {
570 const auto fmt(GetFileType(filename));
571
572 return fmt == ImageFormat::Unknown
573 ? ImageFormat(::FreeImage_GetFIFFromFilename(filename)) : fmt;
574 }
575 ImageFormat
576 ImageCodec::DetectFormat(const char16_t* filename)
577 {
578 const auto fmt(GetFileType(filename));
579
580 return fmt == ImageFormat::Unknown ? GetFormatFromFilename(filename) : fmt;
581 }
582
583 CompactPixmap
584 ImageCodec::Load(ImageMemory::Buffer buf)
585 {
586 ImageMemory mem(std::move(buf));
587
588 if(mem.GetFormat() == ImageFormat::Unknown)
589 throw UnknownImageFormat("Unknown image format found when loading.");
590
591 return HBitmap(mem);
592 }
593
594 HMultiBitmap
595 ImageCodec::LoadForPlaying(const char* path)
596 {
597 const auto fmt(DetectFormat(path));
598
599 return HMultiBitmap(path, fmt, fmt == ImageFormat::GIF
600 ? ImageDecoderFlags::GIF_Playback : ImageDecoderFlags::Default);
601 }
602 HMultiBitmap
603 ImageCodec::LoadForPlaying(const char16_t* path)
604 {
605 const auto fmt(DetectFormat(path));
606
607 return HMultiBitmap(path, fmt, fmt == ImageFormat::GIF
608 ? ImageDecoderFlags::GIF_Playback : ImageDecoderFlags::Default);
609 }
610
611 #undef YF_PixConvSpec
612
613 } // namespace Drawing;
614
615 } // namespace YSLib;
616
CHRLib::fp
std::FILE ConversionState fp
Definition: chrproc.h:88
YSLib::Drawing::handle
handle(::FreeImage_OpenMemory(static_cast< byte * >(buffer.data()), static_cast< ::DWORD >(buffer.size())))
YSLib::Drawing::ImageDecoderFlags::Default
YSLib::Drawing::HMultiBitmap::Lock
HBitmap Lock(size_t=0) const
Definition: Image.cpp:542
YSLib::Drawing::MultiBitmapData
Definition: Image.cpp:409
YSLib::Drawing::CompactPixmap
标准矩形像素图缓冲区。
Definition: ygdi.h:201
YSLib::Drawing::HMultiBitmap::pages
DataPtr pages
Definition: Image.h:509
YSLib::true
bool return true
Definition: DSMain.cpp:177
YSLib::Drawing::ImageMemory::ImageMemory
ImageMemory(const HBitmap &, ImageFormat=ImageFormat::BMP, ImageDecoderFlags=ImageDecoderFlags::Default)
构造：从现有图像打开。
Definition: Image.cpp:215
yunused
#define yunused(...)
标记未使用的表达式。
Definition: ydef.h:697
CHRLib::ToASCII
yconstfn char ToASCII(_tChar c)
任意整数类型字符转换为 ASCII 取值范围兼容的字符。
Definition: chrproc.h:59
YSLib::Drawing::MultiBitmapData::plugin_ref
std::reference_wrapper<::FI_PluginRec > plugin_ref
Definition: Image.cpp:416
YSLib::Drawing::MultiBitmapData::~MultiBitmapData
~MultiBitmapData()
Definition: Image.cpp:456
YSLib::Drawing::MultiBitmapData::read
bool read
Definition: Image.cpp:412
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:555
YSLib::Drawing::MultiBitmapData::DefPred
DefPred(const ynothrow, OpenForRead, read) DefGetter(const ynothrow
YSLib::Drawing::Size::Height
SDst Height
宽和高。
Definition: ygdibase.h:258
YSLib::Drawing::GetAreaOf
yconstfn auto GetAreaOf(const Size &s) ynothrow-> decltype(s.Width *s.Height)
取面积。
Definition: ygdibase.h:404
YSLib::Drawing::MultiBitmapData::io_ref
std::reference_wrapper<::FreeImageIO > io_ref
Definition: Image.cpp:415
YSLib::Drawing::ImageFormat::Unknown
YSLib::Drawing::MultiBitmapData::data
void * data
Definition: Image.cpp:418
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
YSLib::Drawing::BadImageAlloc
图像资源分配失败异常：表示存储等资源不足导致无法创建图像。
Definition: Image.h:134
YSLib::Drawing::MultiBitmapData::LockPage
page_count::FIBITMAP * LockPage(size_t=0) const ynothrow
Definition: Image.cpp:463
YSLib::Drawing::size_t
size_t
Definition: ygdi.h:352
YSLib::Drawing::ImageMemory::Buffer
vector< octet > Buffer
Definition: Image.h:175
YSLib::Drawing::operator==
yconstfn bool operator==(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
比较：屏幕二元组相等关系。
Definition: ygdibase.h:181
YSLib::Drawing::MultiBitmapData::handle
::fi_handle handle
Definition: Image.cpp:413
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
YSLib::Drawing::ImageMemory
图像内存对象；保存图像内容的数据缓冲对象。
Definition: Image.h:170
YSLib::Drawing::ImageMemory::NativeHandle
::FIMEMORY * NativeHandle
Definition: Image.h:173
YSLib::Drawing::bitmap
pixmap bitmap
Definition: Image.cpp:317
platform::Descriptions::Warning
Definition: ycommon.h:75
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::Drawing::UnknownImageFormat
未知图像格式异常：表示请求的操作涉及的图像格式因为不明确而不受库的支持。
Definition: Image.h:157
YSLib::Drawing::HBitmap::GetPixels
byte * GetPixels() const ynothrow
取像素数据。
Definition: Image.cpp:379
YSLib::Drawing::HBitmap::~HBitmap
~HBitmap()
Definition: Image.cpp:340
platform::ufopen
YF_API std::FILE * ufopen(const char *filename, const char *mode) ynothrow
以 UTF-8 文件名打开文件。
Definition: YCLib/FileSystem.cpp:269
YSLib::Drawing::BitPerPixel
u8 BitPerPixel
Definition: Image.h:55
YSLib::Drawing::MultiBitmapData::MultiBitmapData
MultiBitmapData(::fi_handle, int,::FI_PluginRec &,::FreeImageIO &=u8_io, bool=true) ynothrow
Definition: Image.cpp:436
YSLib::Drawing::ImageDecoderFlags::GIF_Playback
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:81
YSLib::Drawing::HMultiBitmap
多页面位图句柄：指向多页面位图数据。
Definition: Image.h:471
YSLib::Drawing::HBitmap::bitmap
DataPtr bitmap
Definition: Image.h:244
YSLib::Drawing::HBitmap::Rescale
PDefH(byte *, GetScanLine, size_t idx) const ynothrow ImplRet(bitmap?(*this) Rescale[idx] void(const Size &, SamplingFilter=SamplingFilter::Box)
取扫描线数据。
Definition: Image.h:414
YSLib::UI::f
_tWidget _fCallable && f
Definition: ywgtevt.h:597
YSLib::Drawing::ImageMemory::handle
NativeHandle handle
Definition: Image.h:179
YSLib::Drawing::HBitmap::HBitmap
HBitmap(DataPtr ptr={}) ynothrow
Definition: Image.h:252
YSLib::Drawing::HBitmap
位图句柄：指向位图数据。
Definition: Image.h:238
platform_ex::Windows::s
return s
Definition: MinGW32.cpp:49
YSLib::Drawing::HBitmap::GetBPP
BitPerPixel GetBPP() const ynothrow
Definition: Image.cpp:364
YSLib::Drawing::ImageDecoderFlags
ImageDecoderFlags
图像解码器标识。
Definition: Image.h:81
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:269
YSLib::LoggedEvent
记录日志的异常事件类。
Definition: yexcept.h:58
YSLib::Drawing::HBitmap::SaveTo
bool SaveTo(const char *, ImageFormat=ImageFormat::BMP, ImageDecoderFlags=ImageDecoderFlags::Default) const ynothrow
\ brief 保存：使用指定 UTF-8 文件名、格式和解码器标识。
Definition: Image.cpp:396
platform::BitmapPtr
PixelType * BitmapPtr
Definition: Video.h:295
YSLib::Drawing::MultiBitmapData::PageCount
PageCount
Definition: Image.cpp:430
YSLib::Drawing::Width
if(YB_UNLIKELY(r >=sGraphics.Height)) throw std return pBuffer r *sGraphics Width
Definition: ygdibase.cpp:155
YSLib::Drawing::MultiBitmapData::page_count
size_t page_count
Definition: Image.cpp:417
YSLib::Drawing::DefGetter
DefGetter(const ynothrow, AlphaType *, BufferAlphaPtr, pBufferAlpha) DefGetter(const ynothrow
取 Alpha 缓冲区的指针。
YSLib::Drawing::format
format(fmt)
Definition: Image.cpp:242
YSLib::Drawing::HMultiBitmap::iterator
Definition: Image.h:477
YModules.h
YSLib::Drawing::bpp
pixmap bpp
Definition: Image.cpp:318
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
ystdex::make_unique
enable_if_t<!is_array< _type >::value, std::unique_ptr< _type > > make_unique(_tParams &&...args)
使用 new 和指定参数构造指定类型的 std::unique_ptr 实例。
Definition: memory.hpp:213
YSLib::Drawing::HMultiBitmap::HMultiBitmap
HMultiBitmap(const char *, ImageDecoderFlags=ImageDecoderFlags::Default)
构造：使用指定 UTF-8 文件名和解码器标识。
Definition: Image.cpp:514
YSLib::Drawing::MultiBitmapData::load_flags
int load_flags
Definition: Image.cpp:414
YSLib::Drawing::Size::Width
SDst Width
Definition: ygdibase.h:258
YSLib::Drawing::UnsupportedImageFormat
未被支持的图像格式异常：表示请求的操作涉及的图像格式不受库的支持。
Definition: Image.h:142
YSLib::Drawing::HBitmap::GetPitch
SDst GetPitch() const ynothrow
Definition: Image.cpp:374
YModules.h
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:73
YSLib::Drawing::ImageMemory::format
ImageFormat format
Definition: Image.h:180
YSLib::Drawing::ImageFormat::GIF
YSLib::Drawing::ImageFormat
ImageFormat
图像格式。
Definition: Image.h:64