Jump to content

stacker_liew

Members
  • Content Count

    106
  • Joined

  • Last visited

  • Days Won

    1

stacker_liew last won the day on June 5 2022

stacker_liew had the most liked content!

Community Reputation

5 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Although ASM is very important in programming language, but no productivity at all, especially in risc environment.
  2. stacker_liew

    ChatGPT Converted Unit

    I use ChatGPT convert a JavaScript script to Delphi (Firemonkey) unit, it seems have error, can anyone check for it. unit LakeEffect; interface uses System.Types, System.Classes, FMX.Controls, FMX.Graphics, FMX.Types, FMX.Objects; type TLakeEffect = class(TImage) private FSpeed: Single; FScale: Single; FWaves: Integer; FImage: Boolean; FCanvas: TCanvas; FFrames: TArray<TBitmap>; FFrame: Integer; FMaxFrames: Integer; FOffset: Single; FImgLoaded: Boolean; procedure CreateFrames; procedure LoadImage(Sender: TObject); procedure TimerTick(Sender: TObject); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Speed: Single read FSpeed write FSpeed; property Scale: Single read FScale write FScale; property Waves: Integer read FWaves write FWaves; property Image: Boolean read FImage write FImage; end; implementation uses System.Math; constructor TLakeEffect.Create(AOwner: TComponent); begin inherited Create(AOwner); FSpeed := 1; FScale := 1; FWaves := 10; FImage := True; FCanvas := TCanvas.Create; FFrames := nil; FFrame := 0; FMaxFrames := 0; FOffset := 0; FImgLoaded := False; end; destructor TLakeEffect.Destroy; begin FCanvas.Free; inherited Destroy; end; procedure TLakeEffect.CreateFrames; var Img: TBitmap; Ca: TBitmap; Id: TBitmapData; Odd: TBitmapData; W, H, DW, DH: Integer; Pixel, J, Displacement, M, N, Sign: Integer; X, Y: Integer; begin Img := TBitmap.Create; try Img.LoadFromFile('path_to_image.jpg'); // 請替換為你的圖像路徑 Ca := TBitmap.Create(Img.Width, Img.Height * 2); Ca.Canvas.BeginScene; Ca.Canvas.DrawBitmap(Img, TRectF.Create(0, 0, Img.Width, Img.Height), TRectF.Create(0, 0, Ca.Width, Ca.Height), 1); Ca.Canvas.Scale := PointF(1, -1); Ca.Canvas.DrawBitmap(Img, TRectF.Create(0, -Img.Height * 2, Img.Width, 0), TRectF.Create(0, -Ca.Height, Ca.Width, 0), 1); Ca.Canvas.EndScene; FCanvas.Assign(Ca.Canvas); W := Ca.Width; H := Ca.Height; DW := W; DH := H div 2; Img.Map(TMapAccess.Read, Id); try Odd.SetSize(W, H); Odd.Map(TMapAccess.Write, Id.PixelFormat); for Y := 0 to DH - 1 do begin for X := 0 to DW - 1 do begin Displacement := Trunc(FScale * 10 * (Sin(DH / (Y / FWaves)) + (-FOffset))); J := ((Displacement + Y) * W + X + Displacement) * 4; if J < 0 then begin Pixel := Pixel + 4; Continue; end; M := J mod (W * 4); N := Trunc(FScale * 10 * (Y / FWaves)); if (M < N) or (M > (W * 4) - N) then begin Sign := IfThen(Y < W / 2, 1, -1); Odd.SetPixel(X, Y, Odd.GetPixel(X, Displacement + Y) * Sign); Continue; end; if Id.GetAlpha(J) <> 0 then begin Odd.SetPixel(X, Y, Id.GetPixel(J)); end else begin Odd.SetPixel(X, Y, Odd.GetPixel(X, Y - W div 2)); end; end; end; FOffset := FOffset + FSpeed; FFrame := FFrame + 1; FFrames := FFrames + [Odd.Clone]; if FOffset > FSpeed * (6 / FSpeed) then begin FOffset := 0; FMaxFrames := FFrame - 1; FFrame := 0; Exit; end; if FOffset <= FSpeed * (6 / FSpeed) then begin CreateFrames; end; finally Img.Unmap(Id); Odd.Unmap; end; finally Ca.Free; Img.Free; end; end; procedure TLakeEffect.LoadImage(Sender: TObject); begin FImgLoaded := True; FCanvas.BeginScene; FCanvas.DrawBitmap(FFrames[FFrame], TRectF.Create(0, FCanvas.Height / 2, FCanvas.Width, FCanvas.Height), TRectF.Create(0, FCanvas.Height / 2, FCanvas.Width, FCanvas.Height), 1); FCanvas.EndScene; FFrame := FFrame + 1; if FFrame > FMaxFrames then begin FFrame := 0; end; end; procedure TLakeEffect.TimerTick(Sender: TObject); begin if FImgLoaded then begin FCanvas.BeginScene; if not FImage then begin FCanvas.DrawBitmap(FFrames[FFrame], TRectF.Create(0, 0, FCanvas.Width, FCanvas.Height div 2), TRectF.Create(0, 0, FCanvas.Width, FCanvas.Height div 2), 1); end else begin FCanvas.DrawBitmap(FFrames[FFrame], TRectF.Create(0, FCanvas.Height div 2, FCanvas.Width, FCanvas.Height), TRectF.Create(0, FCanvas.Height div 2, FCanvas.Width, FCanvas.Height), 1); end; FCanvas.EndScene; FFrame := FFrame + 1; if FFrame > FMaxFrames then begin FFrame := 0; end; end; end; end.
  3. stacker_liew

    Why This App No Screen?

    Thanks
  4. stacker_liew

    Why This App No Screen?

    I use ChatGPT to convert a Vcl Tetris to FMX Version, compile is ok, but no screen, any one can help?FMXTetris.7z FMXTetris.7z
  5. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    Use fingerprint {is deprecated, so untick will be ok}
  6. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    Project->Options->User Permission->Use biometric, Use fingerprint {must tick}
  7. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    I know what happen, I forget to tick two permissions in project option.
  8. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    I'm using Android 12, it skip the Request Permission section. RAD 11.3.1 FMX 64 bits.
  9. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    This is new one. NewBiometricAuthDemo.7z
  10. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    I followed your instruction, still won't work. Here is the source.
  11. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    This is the new one without third party components. NewBiometricAuthDemo.7z
  12. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    Wait...I create another one which without third party component.
  13. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    It should display the request permission dialog, but it won't. I'm using Android 12.
  14. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    I checked the Biometric Authorization Service, still won't work.
  15. stacker_liew

    Any Demo On How To Use TBiometricAuth In Delphi

    OK, thanks.
×