VincentWei / MiniGUI

A modern and mature cross-platform window system for embedded systems and smart IoT devices.
http://www.minigui.com
GNU General Public License v3.0
695 stars 157 forks source link

无后缀的图片文件显示 #79

Closed tirrcute closed 2 years ago

tirrcute commented 3 years ago

您好,请问下minigui有根据文件内容判断图片格式的API嘛,目前读取一张无后缀的图片或者后缀信息错误(比如是png格式,后缀写成jpg格式)的时候bitmap好像加载不出来了。

VincentWei commented 3 years ago

You can do the following steps:

  1. Call MGUI_RWFromFile to create an MG_RWops object.
  2. Call CheckBitmapType function to determine the file type. This function will returns the correct extension name of the image file type if it can be distinguished by MiniGUI.
  3. Call LoadBitmapEx2 or other API to load the bitmap from the MG_RWops object and the extension name returned by CheckBitmapType.
  4. Do something with the newly loaded BITMAP object.
  5. Destroy the MG_RWops object by calling MGUI_RWclose.

Good Luck!