现在要处理JPG图像的分辨率,要做以下几步工作:
1.将导入在Image中的JPG图像截取某一部分,
2.将截取的图像以96的分辨率保存下来.
请高手指教如何实现?
1.将导入在Image中的JPG图像截取某一部分,
2.将截取的图像以96的分辨率保存下来.
请高手指教如何实现?
解决方案 »
- 求解!!串口返回的数据中添加中文说明,具体见文章内容
- ???给定字符串如何截取最后一个不为数字以前的字符串 以及以后为数字的字符串???
- 大家好过年好!!散分!!
- 在DELPHI的动态库中调用问题?
- 静态调用Package的问题,每天在线,解决了马上给分。
- QuickRep为什么不能用其它打印机?
- 一个概念性的问题...
- 我想用DTS进行数据倒入,设定其为每日定时,然后我更改系统时间,为什么没有执行?如何设定倒入时候先删除原来数据?谢谢
- OpenTable: TAction; taction 是什么类型
- Delphi中函数类型的virtual 和 dynamic 有些什么用?区别在哪里? 求教。
- 加夜班的辛苦了,来接分吧!
- delphi中怎么做到for each x in objs
a定义要切图的范围,左上,到右下位置,图片会复制到Image2中。a:TRect;Image2.Picture.Bitmap.Width:=a.Right-a.Left;
Image2.Picture.Bitmap.Height:=a.Bottom-a.top;
SetStretchBltMode(Image2.Picture.Bitmap.Canvas.Handle, COLORONCOLOR);
Image2.Canvas.CopyRect(rect(0,0,a.Right-a.Left,a.Bottom-a.top)
,image1.Picture.Bitmap.Canvas,a);
2.有人可能会说,把JPG图像转成BMP图像不就可以了吗,但是有个问题,就是当把JPG图像转为BMP图像时,其分辨率也发生了改变,好像都为72DPI(可以在PhotoShop中看到这个分辨率)! 所以我才提问,如何可以对JPG图像直接操作的!有没有别的方法?Dear all: 帮帮忙!
2、用这个方法读Jpeg图片。
var
ti:Timage;
begin
ti:=Timage.Create(self);
ti.Visible:=false;
if OpenPictureDialog1.Execute then
begin
ti.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
image1.Picture.Bitmap.Assign(ti.Picture.Graphic);
ti.Free;
end;
get/set JPG resolution? procedure GetResJpg(JPGFile: string);
const
BufferSize = 50;
var
Buffer: string;
Index: integer;
FileStream: TFileStream;
HorzRes, VertRes: Word;
DP: Byte;
Measure: string;
begin
FileStream := TFileStream.Create(JPGFile,
fmOpenReadWrite);
try
SetLength(Buffer, BufferSize);
FileStream.Read(buffer[1], BufferSize);
Index := Pos('JFIF' + #$00, buffer);
if Index > 0 then
begin
FileStream.Seek(Index + 6, soFromBeginning);
FileStream.Read(DP, 1);
case DP of
1: Measure := 'DPI'; //Dots Per Inch
2: Measure := 'DPC'; //Dots Per Cm.
end;
FileStream.Read(HorzRes, 2); // x axis
HorzRes := Swap(HorzRes);
FileStream.Read(VertRes, 2); // y axis
VertRes := Swap(VertRes);
end
finally
FileStream.Free;
end;
end; procedure SetResJpg(name: string; dpix, dpiy: Integer);
const
BufferSize = 50;
DPI = 1; //inch
DPC = 2; //cm
var
Buffer: string;
index: INTEGER;
FileStream: TFileStream;
xResolution: WORD;
yResolution: WORD;
_type: Byte;
begin
FileStream := TFileStream.Create(name,
fmOpenReadWrite);
try
SetLength(Buffer, BufferSize);
FileStream.Read(buffer[1], BufferSize);
index := POS('JFIF' + #$00, buffer);
if index > 0
then begin
FileStream.Seek(index + 6, soFromBeginning);
_type := DPI;
FileStream.write(_type, 1);
xresolution := swap(dpix);
FileStream.write(xresolution, 2);
yresolution := swap(dpiy);
FileStream.write(yresolution, 2);
end
finally
FileStream.Free;
end;
end;
收藏你的代码,谢谢~!
我想获得JPG图片的分辨率,该怎么去做我看了你的代码还不是很明白!!!
请各位老大帮帮忙!
1.如何处理将JPG转为BMP,或将BMP转为JPG,使其分辨率都不会丢失?
2.或者有没有可以直接对JPG图你进行处理的,比如复制图像的某一部分.
再次感谢!