PPAPI Plugin在Windows下是DLL,可以嵌入图片文件,使用Skia绘图时需要根据DLL里的图片文件生成SkBitmap对象。下面是代码:
#include "utils.h"
#include "SkStream.h"
#include "SkImageDecoder.h"
#include <tchar.h>
SkBitmap* loadImageFromResource(UINT resId, LPCTSTR lpType)
{
TCHAR szLog[512] = { 0 };
HMODULE hModule = NULL;
if (FALSE == GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
, (LPCTSTR)loadImageFromResource, &hModule))
{
_stprintf_s(szLog, 512, _T("GetModuleHandleEx failed, error - %d\r\n"), GetLastError());
OutputDebugString(szLog);
return NULL;
}
HRSRC hRsrc = FindResource(hModule, MAKEINTRESOURCE(resId), lpType);
if (hRsrc == NULL)
{
_stprintf_s(szLog, 512, _T("FindResource failed, error - %d\r\n"), GetLastError());
OutputDebugString(szLog);
return NULL;
}
HGLOBAL hImgData = LoadResource(hModule, hRsrc);
if (hImgData == NULL)
{
_stprintf_s(szLog, 512, _T("LoadResource fai

本文介绍了如何在Windows环境下,通过PPAPI插件加载DLL中的图片资源,并利用Skia库将其转化为SkBitmap对象进行绘图。文中提供了相关代码示例,涉及到的资源类型在RC文件中定义,确保与loadImageFromResource调用时的类型匹配。此外,还列举了若干篇关于CEF、PPAPI插件开发和Skia使用的参考资料。
8727

被折叠的 条评论
为什么被折叠?



