Skip to content

Instantly share code, notes, and snippets.

View viniciusfbb's full-sized avatar

Vinícius Felipe Botelho Barbosa viniciusfbb

View GitHub Profile
@avanderw
avanderw / image-grayscale
Last active February 22, 2024 06:15
The following color matrix filter will grayscale an image.
private const matrix:Array = [
0.3, 0.59, 0.11, 0, 0,
0.3, 0.59, 0.11, 0, 0,
0.3, 0.59, 0.11, 0, 0,
0, 0, 0, 1, 0];
private const zero:Point = new Point();
grayscale.bitmapData.applyFilter(image.bitmapData, image.getRect(image), zero, new ColorMatrixFilter(matrix));
@njsmith
njsmith / ucrt-csv.py
Last active June 10, 2024 06:53
Information on linking to the new Windows UCRT
import sys
import subprocess
import csv
def describe_ucrt_lib(platform):
lib_path = "windows-10-sdk/Lib/10.0.10240.0/ucrt/{}/ucrt.lib".format(platform)
output = subprocess.check_output(["nm", lib_path])
output = output.decode("utf-8")
# Output (x86 32-bit) looks like:
@jimmckeeth
jimmckeeth / SetupUbuntu4Delphi22.sh
Last active June 16, 2024 09:33
This script automates the setup of Ubuntu 22.04 LTS for Delphi 11.3 Alexandria
#!/bin/bash
#
# Download and execute with the following:
# curl -L https://embt.co/SetupUbuntu4Delphi22 | bash
#
echo "Updating the local package directory"
sudo apt update
echo "Upgrading any outdated pacakges"
sudo apt full-upgrade -y
echo "Install new packages necessary for Delphi & FMXLinux"
@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
@jimmckeeth
jimmckeeth / manualadb.bat
Last active May 3, 2024 23:58
Manual ADB Deployment from RAD Studio Tools Menu
@echo off
REM Call from Delphi/RAD Studio IDE with the following parameters
REM $PATH($EXENAME) $NAMEONLY($PROJECT)
echo =============================================================
echo Be sure you Compile Android 64 and Deploy [Shift-Ctrl-Alt-F9]
echo.
echo Also set <application android:resizeableActivity="true"> in AndroidManifest.template.xml
echo =============================================================
echo Path: %1
set apk=%2\bin\%2.apk
@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 / 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 / SimpleResize.pas
Created November 7, 2022 17:41
Simple example resizing an image using Skia4Delphi
uses
System.UITypes, Skia;
function GetResizedImage(const AImage: ISkImage; const ANewWidth, ANewHeight: Integer): ISkImage;
var
LSurface: ISkSurface;
begin
LSurface := TSkSurface.MakeRaster(ANewWidth, ANewHeight);
LSurface.Canvas.Clear(TAlphaColors.Null);
LSurface.Canvas.Scale(ANewWidth / AImage.Width, ANewHeight / AImage.Height);
@viniciusfbb
viniciusfbb / KeyName.pas
Created November 28, 2022 15:04
Delphi FMX key name, used in OnKeyDown/OnKeyUp
function KeyName(const AKey: Word): string;
begin
case AKey of
1: Result := 'vkLButton';
2: Result := 'vkRButton';
3: Result := 'vkCancel';
4: Result := 'vkMButton';
5: Result := 'vkXButton1';
6: Result := 'vkXButton2';
8: Result := 'vkBack';