DivMod 函数 DrawAlpha函数
来源:互联网 发布:新闻客户端 网络舆情 编辑:程序博客网 时间:2024/06/05 06:06
DivMod(Dividend: Integer; Divisor: Integer; var Result, Remainder:Integer);
参数
Dividend:整数,被除数
Divisor:整数,除数
Result:整数,商
Remainder:整数,余数
今天开始弄剂量显示 模块了,没我想的那么简单,努力的试试吧,准备在主界面与错误显示界面中添加这部分的代码
另外,关于X-RAY的剂量计算方面的知识几乎没有,求解释啊
函数调用
DrawAlpha(m_pBakBmp, &r, &CPoint(n[i] * BmpLEDNumSize.cx, 0));
函数原型
/************************************************************************************ 函 数: BOOL CBaseCanvas::DrawAlpha(PMyBitmap pDstBmp, CRect *pRect, CPoint *pPoint)* 参 数: pDstBmp 绘制的目标位图对象 pRect 绘制目标区域的位置和大小 pPoint 透明信息位图的绘制源坐标* 返回值: 成功时,返回TRUE。* 说 明: 用于透明效果的绘制。************************************************************************************/BOOL CBaseCanvas::DrawAlpha(PMyBitmap pDstBmp, CRect *pRect, CPoint *pPoint){#ifdef DEBUG_TEXT if (NULL == m_pBmpAlpha) { ::MessageBox(NULL, _T("对象m_pBmpAlpha为空"), _T("绘制函数错误!!"), MB_OK); return FALSE; }#endif int l = pRect->left; int t = pRect->top; int w = pRect->Width(); int h = pRect->Height(); if(!pDstBmp->AlphaBlend(l, t, w, h, m_pBmpAlpha, pPoint->x, pPoint->y, m_bfAlpha)) { return FALSE; } return TRUE;}
virtual BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, CWceUiGenericBitmap* pSrcBmp, int xSrc, int ySrc, BLENDFUNCTION blendFunction); 和微软的AlphaBlend比较类似, x, 目标位图的左上角坐标的x y, 目标位图的左上角坐标的y nWidth, 目标位图的宽度 nHeight, 目标位图的高度 pSrcBmp, 源位图 xSrc, 源位图的左上角坐标的x ySrc, 源位图的左上角坐标的y blendFunction,见微软的AlphaBlend中这个参数的描述 返回TRUE表示成功,FALSE表示失败
微软的AlphaBlend基本结构:
- typedef struct _BLENDFUNCTION {
- BYTE BlendOp;
- BYTE BlendFlags;
- BYTE SourceConstantAlpha;
- BYTE AlphaFormat;
- }BLENDFUNCTION, *PBLENDFUNCTION, *LPBLENDFUNCTION;
This structure controls blending by specifyingthe blending functionsfor source and destination bitmaps.
这里的 the blending functions指的是哪些函数?
我所知道的有一个:
- BOOL UpdateLayeredWindow(
- HWND hwnd,
- HDC hdcDst,
- POINT *pptDst,
- SIZE *psize,
- HDC hdcSrc,
- POINT *pptSrc,
- COLORREF crKey,
- BLENDFUNCTION *pblend,
- DWORD dwFlags
- );
——————————————————————————————
Specifies the source blend operation. Currently, the only source and destination blend operationthat has been defined is AC_SRC_OVER.
目前只有一种混合模式,就是AC_SRC_OVER。Must be zero.
Specifies an alpha transparency value to be used on the entire source bitmap. The SourceConstantAlpha value is combined with any per-pixel alpha values in the source bitmap. If you set SourceConstantAlpha to 0, it is assumed that your image is transparent. When you only want to use per-pixel alpha values, set the SourceConstantAlpha value to 255 (opaque) .
这个参数设定的是源图像将以什么不透明度叠加在目标图像上。0则透明,255则不透明。This member controls the way the source and destination bitmaps are interpreted.
AC_SRC_ALPHA:
This flag is set when the bitmap has an Alpha channel (that is, per-pixel alpha). Because this API uses premultiplied alpha, the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value. For example, if the alpha channel value is x, the red, green and blue channels must be multiplied by x and divided by 0xff before the call.
以上结构体解释完毕,下面是使用事项。
When the AlphaFormat parameter is AC_SRC_ALPHA, the source bitmap must be 32 bpp. If it is not, the AlphaBlend function will fail.
32bpp是真彩色。
When the BlendOp parameter is AC_SRC_OVER , the source bitmap is placed over the destination bitmap based on the alpha values of the source pixels.
If the source bitmap has no per-pixel alpha value (that is, AC_SRC_ALPHA is not set), the SourceConstantAlpha value determines the blend of the source and destination bitmaps, as shown in the following table. Note that SCA is used for SourceConstantAlpha here. Also, SCA is divided by 255 because it has a value that ranges from 0 to 255.
没有alpha通道的话,将按照SourceConstantAlpha 来确定混合效果。混合公式如下:
- Dst.Red = Src.Red * (SCA/255.0) + Dst.Red * (1.0 - (SCA/255.0))
- Dst.Green = Src.Green * (SCA/255.0) + Dst.Green * (1.0 - (SCA/255.0))
- Dst.Blue = Src.Blue * (SCA/255.0) + Dst.Blue * (1.0 - (SCA/255.0))
If the destination bitmap has an alpha channel, then the blend is as follows.
- Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))
If the source bitmap does not use SourceConstantAlpha (that is, it equals 0xFF), the per-pixel alpha determines the blend of the source and destination bitmaps, as shown by the following equations.
如果源图像没有使用SCA,即默认255,叠加效果就只和他的alpha值有关。
- Dst.Red = Src.Red + (1 - Src.Alpha) * Dst.Red
- Dst.Green = Src.Green + (1 - Src.Alpha) * Dst.Green
- Dst.Blue = Src.Blue + (1 - Src.Alpha) * Dst.Blue
- Dest.alpha = Src.Alpha + (1 - SrcAlpha) * Dst.Alpha
- Src.Red = Src.Red * SourceConstantAlpha / 255.0;
- Src.Green = Src.Green * SourceConstantAlpha / 255.0;
- Src.Blue = Src.Blue * SourceConstantAlpha / 255.0;
- Src.Alpha = Src.Alpha * SourceConstantAlpha / 255.0;
- Dst.Red = Src.Red + (1 - Src.Alpha) * Dst.Red
- Dst.Green = Src.Green + (1 - Src.Alpha) * Dst.Green
- Dst.Blue = Src.Blue + (1 - Src.Alpha) * Dst.Blue
- Dst.Alpha = Src.Alpha + (1 - Src.Alpha) * Dst.Alpha
- DivMod 函数 DrawAlpha函数
- divmod数字处理函数
- python divmod()函数
- Python divmod函数
- divmod(a,b)函数
- divmod数字处理函数
- 每天一个函数---divmod函数
- python 函数 —— divmod()
- python函数一日一发--关于divmod函数
- Python标准库:内置函数divmod(a, b)
- python函数日积月累 basestring()、any()、all()、callable()、divmod()
- 6、内置函数hex, oct, bin,divmod的用法
- python中的divmod()函数以及求二进制的方法
- python 内建函数功能函数 abs() coerce() divmod() round() pow()
- Python常用函数总结二(complex, delattr, divmod, enumerate, eval)
- 功能函数,绝对值abs,数据类型转换coerce,把除法和取余结合divmod,指数运算pow,四舍五入round
- DivMod 方法
- 函数
- java第一章笔记
- Linux设备驱动子系统-SD卡
- ListView组件的应用(模拟新浪微博界面)
- C\C++编译器关于变量的内存分配顺序总结
- windows7 IIS上传文件大小限制解决办法
- DivMod 函数 DrawAlpha函数
- 数组 按行,列存储
- 2012年10月9号阿里巴巴笔试(c++)
- MyEclipse中配置struts.xml自动提示
- 推荐几个开源web自动化测试常用的工具
- 在笔记本上安装Microsoft Visual C++ 6.0,怎么安不上啊?
- hdu 4258斜率优化 状态转移要仔细考虑
- nefu495最长k可重区间集问题
- ( poj 2352,poj 3067, poj2481)树状数组题目总结(二)