惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
V
V2EX - 技术
S
Secure Thoughts
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
S
Securelist
S
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
G
GRAHAM CLULEY
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
Intezer
Google Online Security Blog
Google Online Security Blog
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
The Cloudflare Blog
I
InfoQ
L
LangChain Blog
U
Unit 42
P
Proofpoint News Feed
S
Schneier on Security
S
Security Affairs
Y
Y Combinator Blog
T
Tenable Blog
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
量子位
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
AWS News Blog
AWS News Blog

博客园 - 高原

[转] 定义、注册和实现 GObject 类的子类 [转] GType 类型系统的功能 [转] Android FrameWork——Touch事件派发过程详解 [转] GObject对象系统 [转] GTYPE类型系统分析 VC里嵌汇编,获取寄存器的值 [转] 使用dbghelp获取调用堆栈--release下的调试方法学 [转] 探索Win32系统之窗口类(Window Classes in Win32) [转] 编译器开关参数集 [转] Nano-X的详细介绍 [转] microwindows位图解析 [转] Microwindows及其中文化方法 [转] Nano-X显示系统的代码分析 [转] Nano-X图形引擎分析及其优化 [转] 使用 pq magic 分区出现 Error 983 报错信息的处理办法 [转] IncrediBuild 试用时间推迟的算法 [原创] MicroWindows学习笔记之底层消息的读取 [原创] MicroWindows学习笔记之对底层设备的管理 [转载] Makefile详解
[转] 为MicroWindows添加透明绘图函数
高原 · 2011-03-08 · via 博客园 - 高原

用GrLoadImageFromFile()函数时,microwindows将图片解码放进一个图片头结构中,在Mwtypes.h文件中定义如下

typedef struct {
int   width;   /* image width in pixels*/
int   height;   /* image height in pixels*/
int   planes;   /* # image planes*/
int   bpp;   /* bits per pixel (1, 4 or 8)*/
int   pitch;   /* bytes per line*/
int   bytesperpixel; /* bytes per pixel*/
int   compression; /* compression algorithm*/
int   palsize; /* palette size*/
long   transcolor; /* transparent color or -1 if none*/
MWPALENTRY * palette; /* palette*/
MWUCHAR * imagebits; /* image bits (dword right aligned)*/
} MWIMAGEHDR, *PMWIMAGEHDR;


其中transcolor就是图片的透明色。

由于nano-X是C/S结构,绘图函数实现都在服务器端,因此为了添加新的函数,我们必须在客户端和服务器端都添加函数。


-------------------------------------------------------------------------------

修改客户端API

nano-X.h/

void GrSetImageTransColor(GR_IMAGE_ID id, long color);


nanox/Client.c

#if MW_FEATURE_IMAGES
/**
* Set transcolor of a image.
*
* @param id ID of the image buffer to free
*
* @ingroup nanox_image
*/
void
GrSetImageTransColor(GR_IMAGE_ID id, long color)
{
nxSetImageTransColorReq *req;

LOCK(&nxGlobalLock);
req = AllocReq(SetImageTransColor);
req->id = id;
req->color = color;
UNLOCK(&nxGlobalLock);
}
#endif /* MW_FEATURE_IMAGES */

-------------------------------------------------------------------------------

修改绘图引擎层

include/Device.h

int GdSetImageTransColor(int id, long color);


engine/Devimage.c

/**
* Set the transcolor of image.
*
* @param id Image to query.
* @param color for the transcolor.
* @return TRUE on success, FALSE on error.
*/
MWBOOL
GdSetImageTransColor(int id, long color)
{
PMWIMAGEHDR pimage;
PIMAGEITEM pItem;
int   i;

pItem = findimage(id);
if (!pItem) {
   return FALSE;
}
pimage = pItem->pimage;
pimage->transcolor = color;

return TRUE;
}


-------------------------------------------------------------------------------

添加C/S通信协议

nanox/Nxproto.h

#define GrNumSetImageTransColor             125
typedef struct {
BYTE8 reqType;
BYTE8 hilength;
UINT16 length;
IDTYPE id;
UINT32 color;
} nxSetImageTransColorReq;

#define GrTotalNumCalls         126


-------------------------------------------------------------------------------

添加服务器端函数

nanox/Srvfunc.c


/* set the transcolor of image */
void
GrSetImageTransColor(GR_IMAGE_ID id, long color)
{

SERVER_LOCK();

GdSetImageTransColor(id, color);

SERVER_UNLOCK();
}


nanox/Srvnet.c

static void
GrSetImageTransColorWrapper(void *r)
{
nxSetImageTransColorReq *req = r;

GrSetImageTransColor(req->id, req->color);
}

/*
* Handler functions, ordered by reqType
*/
struct GrFunction {
void   (*func)(void *);
GR_FUNC_NAME name;
} GrFunctions[] = {
/*   0 */ {GrOpenWrapper, "GrOpen"},
……
……
……
……
……
……
/* 125 */ {GrSetImageTransColorWrapper, "GrSetImageTransColor"},
};


在实际使用中应该先判断图片颜色位数,在根据颜色位数设置透明色

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/bisword/archive/2008/07/30/2739981.aspx