كود لتحويل ICO الى bmp
procedure TForm1.Button2Click(Sender: TObject);
var
Icon : TIcon;
Bitmap : TBitmap;
begin
if OpenDialog1.Execute then begin
Icon := TIcon.Create;
Bitmap := TBitmap.Create;
Icon.LoadFromFile(OpenDialog1.FileName);
Bitmap.Width := Icon.Width;
Bitmap.Height := Icon.Height;
Bitmap.Canvas.Draw(0, 0, Icon);
Bitmap.SaveToFile('c:\picture.bmp');
Icon.Free;
Bitmap.Free;
end;
end;
//==========================================================
وبالتالي
كود لاستخراج ico من ملف bmp
procedure TForm1.Button1Click(Sender: TObject);
var
IconSizeX: integer;
IconSizeY: integer;
XOrMask: TBitmap;
IconInfo: TIconInfo;
Icon: TIcon;
begin
IconSizeX := GetSystemMetrics(SM_CXICON);
IconSizeY := GetSystemMetrics(SM_CYICON);
XOrMask := TBitmap.Create;
XOrMask.Width := IconSizeX;
XOrMask.Height := IconSizeY;
XOrMask.LoadFromFile('C:\picture.bmp');{}
Form1.Canvas.Draw(IconSizeX * 4, IconSizeY, XOrMask);
{Create a icon}
Icon := TIcon.Create;
IconInfo.fIcon := true;
IconInfo.xHotspot := 0;
IconInfo.yHotspot := 0;
IconInfo.hbmMask := XOrMask.Handle;
IconInfo.hbmColor := XOrMask.Handle;
Icon.Handle := CreateIconIndirect(IconInfo);
{Destroy the temporary bitmaps}
// AndMask.Free;
XOrMask.Free;
{Draw as a test}
Form1.Canvas.Draw(IconSizeX * 6, IconSizeY, Icon);
{Assign the application icon}
Application.Icon := Icon;
{Force a repaint}
InvalidateRect(Application.Handle, nil, true);
{Free the icon}
Icon.Free;
end;
طبعا لازم يكون الملف عبارة من ملف ايونة تم حفظه على بالتنسيق
//============================================================
كود يحول الbmp الى jpg
uses JPEG;
procedure TForm1.Button2Click(Sender: TObject);
var
JPEG: TJPEGImage;
Bitmap: TBitmap;
begin
if OpenDialog1.Execute then
begin
JPEG := TJPEGImage.Create;
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile(OpenDialog1.FileName);
JPEG.Assign(Bitmap);
Image1.Picture.Assign(JPEG);
finally
JPEG.SaveToFile('C:\E.jpg');
JPEG.Free;
Bitmap.Free;
end;
end;
//===============================================================
وهذا كود يحول ال jpg الى bmp
uses JPEG;
procedure TForm1.Button3Click(Sender: TObject);
var
jpeg: TJPEGImage;
bmp: TBitmap;
begin
if OpenDialog1.Execute then
begin
jpeg := TJPEGImage.Create;
try
jpeg.CompressionQuality := 100; {Default Value}
jpeg.LoadFromFile(OpenDialog1.FileName);
bmp := TBitmap.Create;
try
bmp.Assign(jpeg);
bmp.SaveTofile('c:\3.bmp');
finally
bmp.Free
end;
finally
jpeg.Free
end;
end;
end;
//===============================================================
كود لتغيير حجم الصورة
function TForm1.ResizeBmp(bitmp: TBitmap; wid, hei: Integer): Boolean;
var
TmpBmp: TBitmap;
ARect: TRect;
begin
Result := False;
try
TmpBmp := TBitmap.Create;
try
TmpBmp.Width := wid;
TmpBmp.Height := hei;
ARect := Rect(0,0, wid, hei);
TmpBmp.Canvas.StretchDraw(ARect, Bitmp);
bitmp.Assign(TmpBmp);
finally
TmpBmp.Free;
end;
Result := True;
except
Result := False;
end;
end;
//***************************************************
procedure TForm1.Button2Click(Sender: TObject);
begin
ResizeBmp(Image1.Picture.Bitmap,200,700)
end;
//***********************************************************************//
الفورم على شكل صوره
/====================================
type
TRGBArray = array[0..32767] of TRGBTriple;
PRGBArray = ^TRGBArray;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FRegion: THandle;
function CreateRegion(Bmp: TBitmap): THandle;
public
{ Public declarations }
end;
//=======================================================
function TForm1.CreateRegion(Bmp: TBitmap): THandle;
var
X, Y, StartX: Integer;
Excl: THandle;
Row: PRGBArray;
TransparentColor: TRGBTriple;
begin
Bmp.PixelFormat := pf24Bit;
Result := CreateRectRGN(0, 0, Bmp.Width, Bmp.Height);
for Y := 0 to Bmp.Height - 1 do
begin
Row := Bmp.Scanline[Y];
StartX := -1;
if Y = 0 then
TransparentColor := Row[0];
for X := 0 to Bmp.Width - 1 do
begin
if (Row[X].rgbtRed = TransparentColor.rgbtRed) and
(Row[X].rgbtGreen = TransparentColor.rgbtGreen) and
(Row[X].rgbtBlue = TransparentColor.rgbtBlue) then
begin
if StartX = -1 then StartX := X;
end
else
begin
if StartX > -1 then
begin
Excl := CreateRectRGN(StartX, Y, X + 1, Y + 1);
try
CombineRGN(Result, Result, Excl, RGN_DIFF);
StartX := -1;
finally
DeleteObject(Excl);
end;
end;
end;
end;
if StartX > -1 then
begin
Excl := CreateRectRGN(StartX, Y, Bmp.Width, Y + 1);
try
CombineRGN(Result, Result, Excl, RGN_DIFF);
finally
DeleteObject(Excl);
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.LoadFromFile('E:\prgramm\change form\Eagle.bmp');
FRegion := CreateRegion(Bmp);
SetWindowRGN(Handle, FRegion, True);
finally
Bmp.Free;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DeleteObject(FRegion);
end;
//===================================أضاعوني وأي فتى أضاعـوا * * * ليـوم كــريهـة وســـداد ثغــــر
وخـــــلونـي ومعتـرك المنايـا * * * وقد شـــرعوا أسنــتهم لنحـري
كأني لم أكــــــن فيهـم وسيطـا * * * ولم تك نســبتي في آل عمــرو
أجرر في الجـــوامع كـل يـوم * * * ألا لله مظــــلمتـي وهـصـــري
عسى الملك المجيب لمن دعاه * * * سينجيني فيعلم كيــف شكـري
فأجـــزي بالكرامـة أهـل ودي * * * وأجزي بالضـغينة أهل ضري