免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3162 | 回复: 0
打印 上一主题 下一主题

关于pgm格式图片转换成bmp图片 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-01-17 02:10 |只看该作者 |倒序浏览
我现在在写一个浏览器的插件,其中需要把一个存在于内存的pgm格式的图片,转换成能在IE里显示的BMP格式的文件,我现在找到了个例子,是关于把wko格式转成bmp的。
请问这个方法是否可以用在我上面提到的问题里?还有怎么来改?

DWORD WINAPI DecodeFunc(PluginInstance *This)
{
/*    OutputDebugString("Thread Enter: ";
    OutputDebugString(This->;url);
    OutputDebugString("\n";
*/    if (This && This->;valid && This->;bits_read - This->;last_bits_drawn >; 0 && This->;dib)
    {
        t_bit_file *bf;

/*        OutputDebugString("Thread Working: ";
        OutputDebugString(This->;url);
        OutputDebugString("\n";
*/        This->;last_time_drawn = time(NULL);
        This->;update_bits *= 3;
        EnterCriticalSection(&This->;lpbits_lock);
        This->;last_bits_drawn = This->;bits_read;
        bf = bit_open(This->;lpbits, "rm", This->;bits_read);   
        if (bf)
        {
            t_wv_dchannels* dc;
            int ycbcr;

            ycbcr = bit_read(1, bf);
            dc = wv_init_decode_channels(0, bf);
            bit_close(bf, NULL);
            LeaveCriticalSection(&This->;lpbits_lock);

            if (dc)
            {
                wv_pel *r, *g, *b;
                int y, x;

                if (ycbcr && dc->;hdr.num_channels >;= 3)
                { // ycbcr ->; rgb
                    for (y = 0; y < dc->;hdr.oheight; y++)
                        wv_ycbcr_to_rgb(dc->;hdr.width, dc->;channels[0] + y * dc->;hdr.width, dc->;channels[1] + y * dc->;hdr.width,
                            dc->;channels[2] + y * dc->;hdr.width);
                }

                r = dc->;channels[0];
                g = dc->;hdr.num_channels >; 1 ? dc->;channels[1] : dc->;channels[dc->;hdr.num_channels - 1];
                b = dc->;hdr.num_channels >; 2 ? dc->;channels[2] : dc->;channels[dc->;hdr.num_channels - 1];
                EnterCriticalSection(&This->;bitmap_lock);
                GdiFlush();
                for (y = 0; y < This->;wvh.oheight; y++)
                {
                    unsigned int ofs = y * This->;wvh.width;
                    unsigned int* dst = This->;dib_bits + (This->;bi.bmiHeader.biHeight - y - 1) * This->;bi.bmiHeader.biWidth;

                    for (x = 0; x < This->;wvh.owidth; x++)
                    {
                        *dst++ = RGB(min(255, max(0, b[ofs])), min(255, max(0, g[ofs])), min(255, max(0, r[ofs])));
                        ofs++;
                    }
                }
                LeaveCriticalSection(&This->;bitmap_lock);
                wv_done_decode_channels(dc);
            }
        }
        else
            LeaveCriticalSection(&This->;lpbits_lock);

        InvalidateRect(This->;fhWnd, NULL, FALSE);
//        UpdateWindow(This->;fhWnd);
/*        OutputDebugString("Thread Done: ";
        OutputDebugString(This->;url);
        OutputDebugString("\n";
*/    }
    This->;decode_thread = INVALID_THREAD;
    return 0;
}
先在此谢过了。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP