BCB6下设置Graphics::TBitmap的PixelFormat属性为什么不成功?

ddeng 2002-06-24 11:40:18
BCB5下设置Graphics::TBitmap的PixelFormat属性后立即见效,而在BCB6中却不见效,即使刚设置了其为pf24bit,但跟踪却发现其值却是pfDevice,为什么呢?

Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Bmp->LoadFromFile("test.bmp");
Bmp->PixelFormat = pf24bit;
Bmp->SaveToFile("test1.bmp");
delete Bmp;

test.bmp为一256色位图,结果test1.bmp的确是24位真彩,但跟踪却发现PixelFormat始终是pfDevice!!

另外有时发现Graphics::TBitmap的Dormant方法会导致使用ScanLine读取数据保护性错误,不明白为什么。
...全文
146 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
短歌如风 2002-06-24
  • 打赏
  • 举报
回复
是你在调试器中没看到PixelFormat的最新修改数据。把你的工程的优化选项都关掉,然后Build一次再试试。
你可以这样看一下:
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Bmp->LoadFromFile("test.bmp");
Bmp->PixelFormat = pf24bit;

switch(Bmp->PixelFormat)
{
case pfDevice:StatusBar1->SimpleText = "pfDevice";break;
case pf24bit:StatusBar1->SimpleText = "pf24bit";break;
default:StatusBar1->SimpleText = "OtherFormat";break;
}

Bmp->SaveToFile("test1.bmp");
delete Bmp;
Jacky趙家傑 2002-06-24
  • 打赏
  • 举报
回复
我刚刚在BCB6里试过,无问题!文件会变成24bit!而且文件的大小也变了,用windows的“Paint”可以看出文件是24bit!
Version 1.7 ----------- - ADD: Delphi/CBuilder 10.2 Tokyo now supported. - ADD: Delphi/CBuilder 10.1 Berlin now supported. - ADD: Delphi/CBuilder 10 Seattle now supported. - ADD: Delphi/CBuilder XE8 now supported. - ADD: Delphi/CBuilder XE7 now supported. - ADD: Delphi/CBuilder XE6 now supported. - ADD: Delphi/CBuilder XE5 now supported. - ADD: Delphi/CBuilder XE4 now supported. - ADD: Delphi/CBuilder XE3 now supported. - ADD: Delphi/CBuilder XE2 now supported. - ADD: Delphi/CBuilder XE now supported. - ADD: Delphi/CBuilder 2010 now supported. - ADD: Delphi/CBuilder 2009 now supported. - ADD: New demo project FlexCADImport. - FIX: The height of the TFlexRegularPolygon object incorrectly changes with its rotation. - FIX: Added division by zero protect in method TFlexControl.MovePathSegment. - FIX: The background beyond docuemnt wasn't filled when TFlexPanel.DocClipping=True. - FIX: In "Windows ClearType" font rendering mode (OS Windows mode) the "garbage" pixels can appear from the right and from the bottom sides of the painted rectangle of the TFlexText object. - FIX: The result rectangle incorrectly calculated in the TFlexText.GetRefreshRect method. - FIX: Added FPaintCache.rcPaint cleanup in the TFlexPanel.WMPaint method. Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache field moved in the protected class section. Added rcPaint field in FPaintCache that represents drawing rectangle. - ADD: In the text prcise mode (TFlexText.Precise=True) takes into account the rotation angle (TFlexText.Angle). - FIX: Removed FG_NEWTEXTROTATE directive (the TFlexText Precise mode should be used instead). - FIX: The TFlexRegularPolygon object clones incorrectly drawed in case when TFlexRegularPolygon have alternative brush (gradient, texture). - ADD: Add TFlexPanel.InvalidateControl virtual method which calls from TFle

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧