This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 头痛,请熟悉bitmap显示的大侠帮我分析分析。最近在改一个很老的小游戏,用borland C++ 4.5写的。原来显示320*240的bmp,现在要改为显示640*480的bmp,可是改了以后,发现显示出来的图片颜色极其难看。我看老程序里用了象StretchDIBits, CopyDIBBits之类的函数。我只是先改了一下和图像大小相关的参数,结果颜色就一片混乱。这回是什么原因呢?是调色板出了问题吗?可是我还没有改和调色板有关的代码,显示320*240的bmp还是正常的。
-yaozhang(yaozhang);
2003-8-11
{215}
(#1327769@0)
-
8-bit bitmap or 24-bit? I know a little about 8-bit.
-lusi(丑小鸭);
2003-8-11
(#1327780@0)
-
谢谢,是8-bit的。
-yaozhang(yaozhang);
2003-8-11
(#1327781@0)
-
what parameters did you change?
-lusi(丑小鸭);
2003-8-11
(#1327799@0)
-
我只改了两个和源bmp文件大小相关的参数。
-yaozhang(yaozhang);
2003-8-11
{532}
(#1327824@0)
-
okay, the question is: did you make any changes to your source bitmap file -- Images[OffScreen].pDib ? It should be a 640*480 bitmap image.Its dimension should be the same as used in StretchDIBits.
My 2 cents is:
instead of using hardcoded 640 and 480 here, use
((LPBITMAPINFO)Images[OffScreen].pDib)->bmiHeader.biWidth
and
((LPBITMAPINFO)Images[OffScreen].pDib)->bmiHeader.biHeight
So that they will always agree with each other.
When you want to change the bitmap image's dimension, just do the modification at one place.
-lusi(丑小鸭);
2003-8-11
{404}
(#1327893@0)
-
Does it help? How did you solve it?
-lusi(丑小鸭);
2003-8-12
(#1329181@0)
-
还没有搞定。:(昨天后来我把那个显示出来巨难看的图片用屏幕拷贝截下来,和源bmp比较了一下,发现用的palette差别很大。我想也许是设置的palette有问题。请问320和640这两种不同分辨率的bmp图片,读取和设置palette的时候有区别吗?它们都是8-bit的。象StretchDIBits之类的函数,会自己读取和设置palette吗?谢谢。
-yaozhang(yaozhang);
2003-8-12
{278}
(#1329241@0)
-
the pallette info doesn't differ. The pallette for 8-bit bitmap file is defined in RGBQUAD bmiColors[]. bmiColors has 256 entries. If I were you, I would copy the old pallete into the new one and see the result.
-lusi(丑小鸭);
2003-8-12
(#1329251@0)
-
刚才试着把源bmp的palette替换掉显示错误的那个bmp的palette,显示出来的图片仍然很难看。会是什么原因呢?
-yaozhang(yaozhang);
2003-8-12
(#1329265@0)
-
can you send me the original bmp (the small one) and the new bmp (the big one)?
-lusi(丑小鸭);
2003-8-12
(#1329399@0)
-
Can you give me your email please? I will attach those bmps to you.
-yaozhang(yaozhang);
2003-8-12
(#1329404@0)
-
.it's
wanglixia99@yahoo.com
-lusi(丑小鸭);
2003-8-12
{29}
(#1329409@0)
-
Check your email please. Thank you very much.
-yaozhang(yaozhang);
2003-8-12
(#1329417@0)
-
up
-yaozhang(yaozhang);
2003-8-11
(#1327848@0)
-
320*240的显示与640*480的显示不同,这就是为什么最早的游戏(仙剑,金庸等)都是比较模糊的。并不是只改参数或者色彩表就能解决的,还要看显卡的,因为属于SVGA,而不是标准VGA(不过现在的显卡肯定都可以了)。
-vincint(八怪);
2003-8-12
(#1329785@0)
-
能告诉我要注意那几方面的东西吗?谢谢。
-yaozhang(yaozhang);
2003-8-12
(#1329797@0)
-
你可以检查一下调色板的位数设置。我不知道你的BMP是多少色的。在VGA模式下,640X480不能支持256色以上。但是如果使用SVGA,那默认的颜色位数为6bits。你可以用8bits的试一下(当然要先check SVGA的设置,因为有时某些SVGA驱动里位数是固定的)。
-zhbuser(我在干嘛);
2003-8-15
{196}
(#1333188@0)