请问一个关于分辨率和色彩的问题

bluesnail 2001-05-31 12:09:00
主  题:一个关于拷屏的问题,请各位帮个忙
作  者:bluesnail
所属论坛:C++ Builder
问题点数:29
回复次数:0
人气指数:0
发表时间:2001-5-31 11:36:00

以下是一段拷屏的代码,但是只能做到根据现在屏幕的分辨率和颜色来拷屏,但是我想做到根据指定的分辨率和颜色来拷屏。
假如现在屏幕的分辨率是800*600,16位彩色,我想拷下来的是640*480,256色,该怎么样来做呢?请各位帮个忙。
{
TCanvas *Desktop = new TCanvas();
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
TRect SourRect,DestRect;

//要拷的区域
SourRect.Left = 0;
SourRect.Top = 0;
SourRect.Right = 100;
SourRect.Bottom = 100;

DestRect.Left = 0;
DestRect.Top = 0;
DestRect.Right = SourRect.Right - SourRect.Left;
DestRect.Bottom = SourRect.Bottom - SourRect.Top;

Desktop->Handle = GetDC(NULL);
Bmp->Width = DestRect.Right;
Bmp->Height = DestRect.Bottom;
Bmp->Canvas->CopyRect(DestRect, Desktop ,SourRect);
Bmp->SaveToFile("c:\\temp\\temp.bmp");

//以下由你的代码得到
TMemoryStream *JpgStrm = new TMemoryStream();
JpgStrm->Clear();

TJPEGImage *Jpg = new TJPEGImage();
Jpg->CompressionQuality=100;
try
{
Jpg->Assign(Bmp);
Jpg->Compress();
Jpg->SaveToStream(JpgStrm);
Jpg->SaveToFile("C:\\temp\\temp.jpg");
}
__finally
{
delete Jpg;
delete JpgStrm;
}

delete Bmp;
delete Desktop;
}
...全文
67 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Asus 2001-05-31
  • 打赏
  • 举报
回复
gz

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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