- 论坛徽章:
- 0
|
我现在在写一个浏览器的插件,其中需要把一个存在于内存的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;
}
先在此谢过了。。。 |
|