Skip to content

Instantly share code, notes, and snippets.

View viniciusfbb's full-sized avatar

Vinícius Felipe Botelho Barbosa viniciusfbb

View GitHub Profile
@viniciusfbb
viniciusfbb / crc16.pas
Created February 20, 2021 19:36
CRC16 hash in delphi
unit crc16;
interface
function CalcCRC16(AData: PByte; ASize: Integer): Word;
implementation
function CalcCRC16(AData: PByte; ASize: Integer): Word;
// Ported from c source: https://stackoverflow.com/a/10569892/2614619
@viniciusfbb
viniciusfbb / ViaCep.pas
Last active November 24, 2021 08:21
Via CEP Api (Brazil Zip Code api) for Delphi
uses
iPub.Rtl.Refit; // From https://github.com/viniciusfbb/ipub-refit
type
TAddress = record
Erro: Boolean;
Cep: string;
Logradouro: string;
Complemento: string;
Bairro: string;
@viniciusfbb
viniciusfbb / Example.pas
Last active November 1, 2023 12:57
Google Geocoding API for Delphi - AddressToGeolocation and GeolocationToAddress
unit Example;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs;
type
TForm1 = class(TForm)
@viniciusfbb
viniciusfbb / DeviceModel.iOS.pas
Last active January 21, 2024 20:03
Get the device model name in iOS in Delphi (Firemonkey) applications
unit DeviceModel.iOS;
interface
function GetDeviceModelName: string;
function GetDeviceModelPrettyName: string;
implementation
uses
@viniciusfbb
viniciusfbb / StrokePathGradient.pas
Last active June 13, 2022 03:11
[Skia4Delphi] Paint gradient color following a stroke path
unit StrokePathGradient;
interface
uses
System.UITypes, Skia;
procedure DrawPathEndSmothing(const ACanvas: ISkCanvas; const APath: ISkPath;
const APaint: ISkPaint; const AInnerColor, AOuterColor: TAlphaColor;
AStart, AStop: Single; const AInterpolations: Integer);
@viniciusfbb
viniciusfbb / Skia.ResizeImage.pas
Created June 23, 2022 12:36
SkImage resize with Skia4Delphi
function ImageResize(AImage: ISkImage; const ANewWidth, ANewHeight: Integer): ISkImage;
var
LPixels: Pointer;
LImageInfo: TSkImageInfo;
begin
Assert(Assigned(AImage));
if (ANewWidth <= 0) or (ANewHeight <= 0) then
Exit(nil);
if (AImage.Width = ANewWidth) and (AImage.Height = ANewHeight) then
Exit(AImage);
@viniciusfbb
viniciusfbb / LogTail4Delphi.pas
Last active July 6, 2022 15:07
LogTail integration for Delphi
uses
iPub.Rtl.Refit; // https://github.com/viniciusfbb/ipub-refit
type
TLogMessageLevel = (Info, Warning, Error);
TLogMessage = record
Dt: TDateTime;
Level: TLogMessageLevel;
&Message: string;
@viniciusfbb
viniciusfbb / Skia.FitAndCrop.pas
Last active August 18, 2023 06:55
Fit and crop a image using Skia4Delphi
unit Skia.FitAndCrop;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Math,
System.Math.Vectors, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics,
FMX.Objects, Skia, Skia.FMX;
type
@viniciusfbb
viniciusfbb / Sample.Form.Controls.TSkPaintBox.pas
Last active September 15, 2022 20:19
Signature to SVG with Skia4Delphi
{************************************************************************}
{ }
{ Skia4Delphi }
{ }
{ Copyright (c) 2011-2022 Google LLC. }
{ Copyright (c) 2021-2022 Skia4Delphi Project. }
{ }
{ Use of this source code is governed by a BSD-style license that can be }
{ found in the LICENSE file. }
{ }
@viniciusfbb
viniciusfbb / Skia.Sample.DropShadow.dfm
Last active September 18, 2022 03:18
Simple sample to drop shadow in image with skia4delphi
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 442
ClientWidth = 628
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12