FBI 叠加自定义中文字库 做OSD用,或者叠加其他信息

 2 E币 
成为会员,免费下载资料
文件大小:991.6 KB 上传者:ngswfx 时间:2016-06-22 19:02:29 下载量:250
本帖最后由 ngswfx 于 2016-6-22 19:07 编辑

[quote][url=forum.php?mod=redirect&goto=findpost&pid=32200&ptid=11624]ngswfx 发表于 2016-6-22 18:59[/url]
不错,有点意思了[/quote]

///////////关键部分代码  附件中有字库,不过字库就大一些了,不知道打包到文件会压缩成怎样。

//下面的代码我没试过,可能需要自己根据字库修改。下面的代码肯定不是1555的,应该是YUV 中针对Y这部分
//32*32 hzk
unsigned long __stdcall        ShowOSD32Ex(unsigned char *pBase, char *pStr, unsigned short x, unsigned short y, unsigned short space, unsigned char Lum, int width, int height, int stride)
{
        Int8 q=3, w, asc=0,*p=(Int8 *)pStr;
        UInt8 *pHZLib=0;
        UInt32 nChar=0,wd=0,nOffset=0,nSize, l, r;
        float fsize = 0,fwd = 0;       
        Int8        *pp = p, num=0;       
        x = UCLIPI(x, width-48);
        y = UCLIPI(y, height-24);
        pBase += stride*y*2+x*2;
        while (*p) {               
                pp = p;
                q = *p&0x80?(*p++)-161:2; // Get qu code
                w=((*p++)&0x7f)-33; // Get wei code               
                if ((nOffset = q*94+w) >= g_real_HZ16_count)
                        continue;
                //32*32
                pHZLib = (HZ32Lib+(nOffset<<7));               
                if (q<10) {
                        l = UBYTESEL(HZ16_Space[nOffset],1)*2;
                        r = UBYTESEL(HZ16_Space[nOffset],0)*2;
                        nSize = HZ32LIB_ZISE-(l+r);//+space;
                        fsize = 20.2;
                }
                else {
                        nSize = HZ32LIB_ZISE+space;
                        l = r = 0;
                        fsize = 40.4;
                }               
                if (x+(int)fwd+(int)fsize+2>width)
                        break;               
                // Draw here
                DrawOSD32(pBase+wd+nChar*(16-r-l), (unsigned int *)pHZLib,Lum,64,stride);
                nChar++;
                wd += nSize;
                fwd += fsize;
        }       
        return nChar;
}
void DrawOSD32(unsigned char *buf, unsigned int *hzLib, char lum, char bklum, int stride)
{
        static unsigned char fontlum[] = {64,192};
        int i, font;
        int        lumi,chroma_u,chroma_v;
        int *p1 = (int *) buf+(stride<<4);
        float mult_f = lum?0.20:1;
        float mult_b = 1 - mult_f;

        int avglum = (buf[0] + buf[2] + buf[4] + buf[6] + buf[8] +
                buf[10] + buf[12] + buf[14] + buf[16] + buf[18] + buf[20] +
                buf[22] + buf[24] + buf[26] + buf[28] + buf[30] +buf[32] +
                buf[34] + buf[36] + buf[38] + buf[40] + buf[42] +buf[44] +
                buf[46] + buf[48] + buf[50] +buf[52] +buf[54] +buf[56] +
                buf[58] + buf[60] +buf[62])/32;

        if(avglum>135)
                lumi = 0x1;
        else
                lumi = 0xff;

        //lumi = 0xff;
        chroma_u = 0x80;
        chroma_v = 0x80;

        for (i=0; i<32; i++) {
                font = *hzLib ++;
/*
                buf[0]   = MUX(font&0x0080, lumi, buf[0] );
                buf[2]   = MUX(font&0x0040, lumi, buf[2] );
                buf[4]   = MUX(font&0x0020, lumi, buf[4] );
                buf[6]   = MUX(font&0x0010, lumi, buf[6] );
                buf[8]   = MUX(font&0x0008, lumi, buf[8] );
                buf[10]   = MUX(font&0x0004, lumi,buf[10]);
                buf[12]   = MUX(font&0x0002, lumi,buf[12]);
                buf[14]   = MUX(font&0x0001, lumi,buf[14]);
                buf[16]   = MUX(font&0x8000, lumi,buf[16]);
                buf[18]   = MUX(font&0x4000, lumi,buf[18]);
                buf[20] = MUX(font&0x2000, lumi,  buf[20]);
                buf[22] = MUX(font&0x1000, lumi,  buf[22]);
                buf[24] = MUX(font&0x0800, lumi,  buf[24]);
                buf[26] = MUX(font&0x0400, lumi,  buf[26]);
                buf[28] = MUX(font&0x0200, lumi,  buf[28]);
                buf[30] = MUX(font&0x0100, lumi,  buf[30]);
*/
                buf[0]   = (unsigned char)(MUX(font&0x0080, lumi*mult_f+buf[0]*mult_b, buf[0] ));
                buf[2]   = (unsigned char)(MUX(font&0x0040, lumi*mult_f+buf[2]*mult_b, buf[2] ));
                buf[4]   = (unsigned char)(MUX(font&0x0020, lumi*mult_f+buf[4]*mult_b, buf[4] ));
                buf[6]   = (unsigned char)(MUX(font&0x0010, lumi*mult_f+buf[6]*mult_b, buf[6] ));
                buf[8]   = (unsigned char)(MUX(font&0x0008, lumi*mult_f+buf[8]*mult_b, buf[8] ));
                buf[10]   = (unsigned char)(MUX(font&0x0004, lumi*mult_f+buf[10]*mult_b,buf[10]));
                buf[12]   = (unsigned char)(MUX(font&0x0002, lumi*mult_f+buf[12]*mult_b,buf[12]));
                buf[14]   = (unsigned char)(MUX(font&0x0001, lumi*mult_f+buf[14]*mult_b,buf[14]));
                buf[16]   = (unsigned char)(MUX(font&0x8000, lumi*mult_f+buf[16]*mult_b,buf[16]));
                buf[18]   = (unsigned char)(MUX(font&0x4000, lumi*mult_f+buf[18]*mult_b,buf[18]));
                buf[20] = (unsigned char)(MUX(font&0x2000, lumi*mult_f+buf[20]*mult_b,  buf[20]));
                buf[22] = (unsigned char)(MUX(font&0x1000, lumi*mult_f+buf[22]*mult_b,  buf[22]));
                buf[24] = (unsigned char)(MUX(font&0x0800, lumi*mult_f+buf[24]*mult_b,  buf[24]));
                buf[26] = (unsigned char)(MUX(font&0x0400, lumi*mult_f+buf[26]*mult_b,  buf[26]));
                buf[28] = (unsigned char)(MUX(font&0x0200, lumi*mult_f+buf[28]*mult_b,  buf[28]));
                buf[30] = (unsigned char)(MUX(font&0x0100, lumi*mult_f+buf[30]*mult_b,  buf[30]));
               
                buf[32] = (unsigned char)(MUX(font&0x800000,lumi*mult_f+buf[32]*mult_b,buf[32]));
                buf[34] = (unsigned char)(MUX(font&0x400000,lumi*mult_f+buf[34]*mult_b, buf[34]));
                buf[36] = (unsigned char)(MUX(font&0x200000, lumi*mult_f+buf[36]*mult_b, buf[36] ));
                buf[38] = (unsigned char)(MUX(font&0x100000, lumi*mult_f+buf[38]*mult_b, buf[38] ));
                buf[40] = (unsigned char)(MUX(font&0x080000, lumi*mult_f+buf[40]*mult_b, buf[40] ));
                buf[42] = (unsigned char)(MUX(font&0x040000, lumi*mult_f+buf[42]*mult_b,buf[42]));
                buf[44] = (unsigned char)(MUX(font&0x020000, lumi*mult_f+buf[44]*mult_b,buf[44]));
                buf[46] = (unsigned char)(MUX(font&0x010000, lumi*mult_f+buf[46]*mult_b,buf[46]));
                buf[48] = (unsigned char)(MUX(font&0x80000000, lumi*mult_f+buf[48]*mult_b,buf[48]));
                buf[50] = (unsigned char)(MUX(font&0x40000000, lumi*mult_f+buf[50]*mult_b,buf[50]));
                buf[52] = (unsigned char)(MUX(font&0x20000000, lumi*mult_f+buf[52]*mult_b,buf[52]));
                buf[54] = (unsigned char)(MUX(font&0x10000000, lumi*mult_f+buf[54]*mult_b,buf[54]));
                buf[56] = (unsigned char)(MUX(font&0x08000000, lumi*mult_f+buf[56]*mult_b,buf[56]));
                buf[58] = (unsigned char)(MUX(font&0x04000000, lumi*mult_f+buf[58]*mult_b,buf[58]));
                buf[60] = (unsigned char)(MUX(font&0x02000000, lumi*mult_f+buf[60]*mult_b,buf[60]));
                buf[62] = (unsigned char)(MUX(font&0x01000000, lumi*mult_f+buf[62]*mult_b,buf[62]));               
               
                buf[1]   = (unsigned char)(MUX(font&0x0080, chroma_u, buf[1] ));
                buf[3]   = (unsigned char)(MUX(font&0x0040, chroma_v, buf[3] ));
                buf[5]   = (unsigned char)(MUX(font&0x0020, chroma_u, buf[5] ));
                buf[7]   = (unsigned char)(MUX(font&0x0010, chroma_v, buf[7] ));
                buf[9]   = (unsigned char)(MUX(font&0x0008, chroma_u, buf[9] ));
                buf[11]   = (unsigned char)(MUX(font&0x0004, chroma_v,buf[11]));
                buf[13]   = (unsigned char)(MUX(font&0x0002, chroma_u,buf[13]));
                buf[15]   = (unsigned char)(MUX(font&0x0001, chroma_v,buf[15]));
                buf[17]   = (unsigned char)(MUX(font&0x8000, chroma_u,buf[17]));
                buf[19]   = (unsigned char)(MUX(font&0x4000, chroma_v,buf[19]));
                buf[21] = (unsigned char)(MUX(font&0x2000, chroma_u,  buf[21]));
                buf[23] = (unsigned char)(MUX(font&0x1000, chroma_v,  buf[23]));
                buf[25] = (unsigned char)(MUX(font&0x0800, chroma_u,  buf[25]));
                buf[27] = (unsigned char)(MUX(font&0x0400, chroma_v,  buf[27]));
                buf[29] = (unsigned char)(MUX(font&0x0200, chroma_u,  buf[29]));
                buf[31] = (unsigned char)(MUX(font&0x0100, chroma_v,  buf[31]));

                buf[33]   = (unsigned char)(MUX(font&0x800000, chroma_u, buf[33] ));
                buf[35]   = (unsigned char)(MUX(font&0x400000, chroma_v, buf[35] ));
                buf[37]   = (unsigned char)(MUX(font&0x200000, chroma_u, buf[37] ));
                buf[39]   = (unsigned char)(MUX(font&0x100000, chroma_v, buf[39] ));
                buf[41]   = (unsigned char)(MUX(font&0x080000, chroma_u, buf[41] ));
                buf[43]   = (unsigned char)(MUX(font&0x040000, chroma_v,buf[43]));
                buf[45]   = (unsigned char)(MUX(font&0x020000, chroma_u,buf[45]));
                buf[47]   = (unsigned char)(MUX(font&0x010000, chroma_v,buf[47]));
                buf[49]   = (unsigned char)(MUX(font&0x80000000, chroma_u,buf[49]));
                buf[51]   = (unsigned char)(MUX(font&0x40000000, chroma_v,buf[51]));
                buf[53] = (unsigned char)(MUX(font&0x20000000, chroma_u,  buf[53]));
                buf[55] = (unsigned char)(MUX(font&0x10000000, chroma_v,  buf[55]));
                buf[57] = (unsigned char)(MUX(font&0x08000000, chroma_u,  buf[57]));
                buf[59] = (unsigned char)(MUX(font&0x04000000, chroma_v,  buf[59]));
                buf[61] = (unsigned char)(MUX(font&0x02000000, chroma_u,  buf[61]));
                buf[63] = (unsigned char)(MUX(font&0x01000000, chroma_v,  buf[63]));
               
                buf += stride*2;
        }
}
展开
折叠
2566
评论
共 0 个
内容存在敏感词
    易百纳技术社区暂无数据
相关资料
更多相关资料
关于作者
易百纳技术社区
ngswfx
贡献资料 40
易百纳技术社区 我上传的资料
登录查看
我赚取的积分
登录查看
我赚取的收益
登录查看
上传资料 赚取积分兑换E币
易百纳技术社区
删除原因
广告/SPAM
恶意灌水
违规内容
文不对题
重复发帖
置顶时间设置
结束时间
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-资料模块

审核失败

失败原因
备注
易百纳技术社区