如何改变一个JPEG图片的大小为一特定宽高度?

onlysgirl 2003-06-13 03:40:13
怎么做呢?
在TJPEGImage中有个scale不知道如何去用它

比如说我装入一个1280*1024的图片我想把它变成100*80的图片并存盘,怎么做呢?
...全文
344 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
houzy123 2003-06-14
  • 打赏
  • 举报
回复
给你一段代码,自己看看,处理图片其原理是一样的,具体另存jpg是比较简单
ProgressBar1->Position=0;
TRect AAA,ARect ;
Graphics::TBitmap *Bitmap;

DBImage1->CopyToClipboard();
DBImage1->PasteFromClipboard();
if (Clipboard()->HasFormat(CF_BITMAP))
{
Bitmap = new Graphics::TBitmap();
try{
Bitmap->Assign(Clipboard());
float xw,xh;//,s_h,n_h,s_w,n_w;

int x_h=200;
int x_w=x_h*((float)Bitmap->Width/(float)Bitmap->Height);
TImage *Imagex=new TImage(image_proc);
Imagex->Parent=ScrollBox1;
Imagex->AutoSize=false;
Imagex->Left=3;
Imagex->Top=4;
Imagex->Visible=true;
Imagex->Width=x_w;
Imagex->Height=x_h;
Imagex->Name="Image2";

xh=(float)Bitmap->Height/(float)Imagex->Height;
xw=(float)Bitmap->Width/(float)Imagex->Width;
ProgressBar1->Max=Imagex->Height;
for(int i=0;i<=Imagex->Height;i++)
{
for(int j=0;j<=Imagex->Width;j++)
{
AAA = Rect(j,i,j+1,i+1);
ARect = Rect(xw*j,xh*i,xw*j+1,xh*i+1);
Imagex->Canvas->CopyRect(AAA, Bitmap->Canvas, ARect);

}
ProgressBar1->Position=i;
}
//Imagex->AutoSize=true;
delete Bitmap;
Bitmap=NULL;
}
catch(...){
delete Bitmap;
Bitmap=NULL;
}
}
ProgressBar1->Position=0;
Chimae 2003-06-14
  • 打赏
  • 举报
回复
TJPEGImage先转换成Bitmap,StrengthDraw好了之后,在转换成TJPEGImage图片保存!
Chimae 2003-06-14
  • 打赏
  • 举报
回复
大小在TRect中定义!
StrengthDraw(TRect(), TGraphic::Bitmap)
codecb 2003-06-14
  • 打赏
  • 举报
回复
到我网站上去我做了个例子
http://nullspace.cnwindows.com
onlysgirl 2003-06-13
  • 打赏
  • 举报
回复
up

13,874

社区成员

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

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