?? covertbmp.pas
字號:
unit CovertBmp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ActnList,jpeg,math,extctrls;
type
TBMInfo = record
bmType, //Bitmap類型
bmWidth, //圖像寬度(像素值)
bmHeight, //圖像高度(像素值)
bmWidthBytes: longint; //每條掃描線指定的字節數
bmPlanes, //指定顏色位
bmBitsPixel: word; //色彩值
//bmBits; //指向位圖值地址
end;
Function CheckBmp(image: TImage;SourceName:string):Integer;
function ConvertToBmp(image1:Timage;DestionName:String):string;
implementation
Function CheckBmp(image: TImage;SourceName:string):Integer;
var
bmInfo:TBMInfo;
bmp:TBitmap;
Ext:String;
begin
if not FileExists(SourceName) then
begin
result:=-1;
exit;
end;
Ext:=LowerCase(ExtractFileExt(SourceName));
if Ext='.bmp' then
begin
Screen.Cursor := crHourGlass;
try
image.Picture.LoadFromFile(SourceName);
Image.top:=0;
Image.left:=0;
if Image.Picture.Graphic is TJPEGImage then
begin
bmp:=TBitmap.Create;
bmp.Assign(TJPEGImage(Image.Picture.Graphic));
end
else bmp:=Image.Picture.Bitmap;
GetObject(bmp.Handle,SizeOf(bmInfo),@bmInfo);
case bmInfo.bmBitsPixel of
24: result:=24;
16: result:=16;
else result:=Trunc(IntPower(2,bmInfo.bmBitsPixel));
end;
if(Image.Picture.Graphic is TJPEGImage) then bmp.free;
finally
Screen.Cursor := crDefault;
end;
end else Result:=-1;
end;
function ConvertToBmp(image1:Timage;DestionName:String):string;
var
bmp:TBitmap;
i:integer;
Picture:TPicture;
begin
// Picture:= TPicture.Create;
try
bmp := TBitmap.Create;
image1.Picture.LoadFromFile(DestionName);
Picture:=image1.Picture;
if ( Picture.Graphic is TBitmap) then
begin
with Bmp do
begin
Width := Picture.Width;
Height := Picture.Height;
PixelFormat := pf8Bit;
Canvas.Draw(0, 0, Picture.Graphic);
end;
Picture.Bitmap.Assign(Bmp);
i:=Pos('.',DestionName);
bmp.SaveToFile(Copy(DestionName,1,i-1)+'.Bmp');
end else if Picture.Graphic is TJPEGImage then
begin
bmp:=TBitmap.create;
bmp.Assign(TJPEGImage(Picture.Graphic));
bmp.PixelFormat:=pf8bit;
i:=Pos('.',DestionName);
bmp.SaveToFile(Copy(DestionName,1,i-1)+'.Bmp');
result:=Copy(DestionName,1,i-1)+'.Bmp';
bmp.free;
result:=Copy(DestionName,1,i-1)+'.Bmp';
end;
except
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -