{ VCL TBitmap Helper }
{ Supplemental methods to TBitmap for supporting }
{ rotate, flip, mirror, etc. }
{ version 0.01 }
{ written by DG, 2020-03-14 }
// the function TBitmapHelper.Rotate(Rads: single; ...) references to
// following STACKOVERFLOW thread:
// https://stackoverflow.com/questions/10633400/rotate-bitmap-by-real-angle
procedure TBitmapHelper.Rotate(Rads: single; Clockwise: boolean = false;
AdjustSize: boolean = true; BkColor: TColor = clWhite);
var
C: Single;
S: Single;
Tmp: Vcl.graphics.TBitmap;
OffsetX: Single;
OffsetY: Single;
Points: array[0..2] of TPoint;
begin
if not Clockwise then // counterclockwise
begin
Rads := Frac(Rads / PI * PI);
if Rads < 0 then
Rads := PI * 2 + Rads
else
Rads := PI * 2 - Rads;
end;
if ABitmap.PixelFormat in [pfDevice, pf1bit, pf4bit, pfCustom] then
begin
if ABitmap.PixelFormat = pfDevice then
Tmp.PixelFormat := pf32bit
else
Tmp.PixelFormat := pf8bit;
Tmp.SetSize(ABitmap.Width, ABitmap.Height);
Tmp.Canvas.Draw(0, 0, ABitmap);
ABitmap.Assign(Tmp);
end
else
Tmp.PixelFormat := ABitmap.PixelFormat;
Tmp.SetSize(ABitmap.Height, ABitmap.Width);
if ABitmap.PixelFormat = pf8bit then
SelectPalette(Tmp.Canvas.Handle, ABitmap.Palette, false);
GetObject(ABitmap.Handle, sizeof(BMP), @BMP);
if BMP.bmBitsPixel >= 8 then
begin
PixelSize := (BMP.bmBitsPixel + 7) div 8;
SrcLineSize := BMP.bmWidthBytes;
Src := BMP.bmBits;
GetObject(Tmp.Handle, sizeof(BMP), @BMP);
DestLineSize := BMP.bmWidthBytes;
Dest := BMP.bmBits;
case PixelSize of
1:
begin
PSrc.P1 := Src;
if Clockwise then
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P1 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P1[i] := PSrc.P1[ABitmap.Width - 1 - j];
Inc(NativeInt(PDest.P1), DestLineSize);
end;
Inc(nativeInt(PSrc.P1), SrcLineSize);
end
else
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P1 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P1[Tmp.Width - i - 1] := PSrc.P1[j];
Inc(NativeInt(PDest.P1), DestLineSize);
end;
Inc(nativeInt(PSrc.P1), SrcLineSize);
end;
end;
2:
begin
PSrc.P2 := Src;
if Clockwise then
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P2 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P2[i] := PSrc.P2[ABitmap.Width - 1 - j];
Inc(NativeInt(PDest.P2), DestLineSize);
end;
Inc(nativeInt(PSrc.P2), SrcLineSize);
end
else
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P2 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P2[Tmp.Width - i - 1] := PSrc.P2[j];
Inc(NativeInt(PDest.P2), DestLineSize);
end;
Inc(nativeInt(PSrc.P2), SrcLineSize);
end;
end;
3:
begin
PSrc.P3 := Src;
if Clockwise then
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P3 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P3[i] := PSrc.P3[ABitmap.Width - 1 - j];
Inc(NativeInt(PDest.P3), DestLineSize);
end;
Inc(nativeInt(PSrc.P3), SrcLineSize);
end
else
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P3 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P3[Tmp.Width - i - 1] := PSrc.P3[j];
Inc(NativeInt(PDest.P3), DestLineSize);
end;
Inc(nativeInt(PSrc.P3), SrcLineSize);
end;
end;
4:
begin
PSrc.P4 := Src;
if Clockwise then
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P4 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P4[i] := PSrc.P4[ABitmap.Width - 1 - j];
Inc(NativeInt(PDest.P4), DestLineSize);
end;
Inc(nativeInt(PSrc.P4), SrcLineSize);
end
else
for i := 0 to ABitmap.Height - 1 do
begin
PDest.P4 := Dest;
for j := 0 to ABitmap.Width - 1 do
begin
PDest.P4[Tmp.Width - i - 1] := PSrc.P4[j];
Inc(NativeInt(PDest.P4), DestLineSize);
end;
Inc(nativeInt(PSrc.P4), SrcLineSize);
end;
end;
end;
end;
ABitmap.Assign(Tmp);
Tmp.Free;
end;
procedure TBitmapHelper.Rotate(Direction: TDirection; Clockwise: boolean = false);
begin
case Direction of
dir90:
__RotateBitmap90(Self, Clockwise);
dir180:
Self.FlipAndMirror;
dir270:
__RotateBitmap90(Self, not Clockwise);
end;
end;
應該大部分可以,依據https://wiki.freepascal.org/Lazarus_For_Delphi_Users 上的說明:
Lazarus is a Rapid Application Development (RAD) tool like Delphi. That means it comes with a visual component library and an Integrated Development Environment (IDE). The Lazarus component library (LCL) is very similar to Delphi's Visual Component Library (VCL). Most Lazarus units, classes and properties have the same name and functionality as their equivalents in Delphi. This makes porting Delphi applications to Lazarus relatively easy. Even though Lazarus is in many respects an open source Delphi clone, the compatibility is not 100%.
uj5u.com熱心網友回復:
應該大部分可以,依據https://wiki.freepascal.org/Lazarus_For_Delphi_Users 上的說明:
Lazarus is a Rapid Application Development (RAD) tool like Delphi. That means it comes with a visual component library and an Integrated Development Environment (IDE). The Lazarus component library (LCL) is very similar to Delphi's Visual Component Library (VCL). Most Lazarus units, classes and properties have the same name and functionality as their equivalents in Delphi. This makes porting Delphi applications to Lazarus relatively easy. Even though Lazarus is in many respects an open source Delphi clone, the compatibility is not 100%.
眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......
值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......