New Hosting

ads auto

Wednesday, December 25, 2024

Lazarus Detect Unicode of keyboard all language

 Detect Unicode Keyboard in Lazarus all Language

Set Windows keyboard and language.

Go to Control Panel > Time & Language > Language & Region > Add a language.
Add Keyboard, language as we want instance Thai, which in this example would use Thai charactor.
Switch to the Thai keyboard layout when testing.
Check Windows Locale and Keyboard
Go to Control Panel > Region:
Under the Formats tab, set the format to Thai.
Under the Administrative tab, set the Language for non-Unicode programs to Thai.


In Lazarus Project before build

Enable Full UTF-8 Support in Lazarus
Go to Project > Project Options > Application.
Ensure Use ANSI code page as UTF-8 is checked.
Set the Font property of Form, Edit1: 
CharSet : set to UNICODE
Font Name to one that supports Thai characters, such as:
Tahoma
Arial Unicode MS
Noto Sans Thai

* Note: Locale language as we want, for this example use Thai character to be reference



Starting Code

Use unit part:

LazUTF8,LCLProc, LConvEncoding

Create function to convert integer to binary

function IntToBin(Value: LongInt; Digits: Integer): string; var i: Integer; begin 
 Result := ''; 
 for i := Digits - 1 downto 0 do 
  begin 
   if (Value and (1 shl i)) <> 0 then 
   Result := Result + '1' else Result := Result + '0'; 
 end; 
end;

Create Function convert or Decode UTF8 to Unicode

function DecodeUTF8ToUnicode(const Utf8Str: string): LongInt;
var
  Byte1, Byte2, Byte3, Byte4: Byte;
  Len: Integer;
begin
  Result := -1; // Default to invalid
  Len := Length(Utf8Str);

  if Len = 1 then
  begin
    Byte1 := Byte(Utf8Str[1]);
    Result := Byte1; // ASCII or single-byte UTF-8
  end
  else if Len = 2 then
  begin
    Byte1 := Byte(Utf8Str[1]);
    Byte2 := Byte(Utf8Str[2]);
    Result := ((Byte1 and $1F) shl 6) or (Byte2 and $3F);
  end
  else if Len = 3 then
  begin
    Byte1 := Byte(Utf8Str[1]);
    Byte2 := Byte(Utf8Str[2]);
    Byte3 := Byte(Utf8Str[3]);
    Result := ((Byte1 and $0F) shl 12) or ((Byte2 and $3F) shl 6) or (Byte3 and $3F);
  end
  else if Len = 4 then
  begin
    Byte1 := Byte(Utf8Str[1]);
    Byte2 := Byte(Utf8Str[2]);
    Byte3 := Byte(Utf8Str[3]);
    Byte4 := Byte(Utf8Str[4]);
    Result := ((Byte1 and $07) shl 18) or ((Byte2 and $3F) shl 12) or ((Byte3 and $3F) shl 6) or (Byte4 and $3F);
  end;
end;  

Edit1 OnUTF8KeyPress Events

procedure TForm1.Edit1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
var
  UnicodeValue: LongInt;
  Utf8Str: string;
begin
  // UTF8Key contains the full UTF-8 character
  Utf8Str := UTF8Key;

  // Decode the Unicode code point
  UnicodeValue := DecodeUTF8ToUnicode(Utf8Str);

  // Display debug information
  //ShowMessage('Key: ' + Utf8Str);
  //ShowMessage('Unicode Value: ' + IntToStr(UnicodeValue));

  // Display Unicode values
  if UnicodeValue > 0 then
  begin
    Declbl.Caption := IntToStr(UnicodeValue);       // Decimal representation
    Hexlbl.Caption := IntToHex(UnicodeValue, 4);    // Hexadecimal representation
    Binlbl.Caption := IntToBin(UnicodeValue, 16);   // Binary representation
  end
  else
  begin
    Declbl.Caption := 'Error';
    Hexlbl.Caption := 'Error';
    Binlbl.Caption := 'Error';
  end;
end;

Debugging Trick

ShowMessage to confirm the contents of Utf8Str and UnicodeValue.

The Result After comply Lazarus project to detect unicode key code all language as below:




Sunday, January 21, 2024

Multiple ControlNets and T2I-Adapters ComfyUI

 Multiple ControlNets and T2I-Adapters ComfyUI

Check Point Name: AOM31A1.safetensors
Prompt:
(solo) girl photograph realistic (flat chest:0.9), (fennec ears:1.0) (fox ears:1.0), (messy hair) blonde hair, blue eyes, standing, serafuku sweater, (brick house) (scenery HDR landscape) (sun clounds) sky, mountains,

Negative Prompt: 
(hands), text, error, cropped, (worst quality:1.2), (low quality:1.2, normal quality, (jpeg artifacts:1.3), signature, watermark, username, blurry, artist name, monochrome, sketch, censorship, censor, (copyright:1.2), extra legs, (forehead mark), (depth of field) (emotionless) (penis)


Empty Latent Image:
width 768
height 768
batch_size 1

KSampler
Seed xxxx
contro_after_generate : Randomize
steps: 12
cfg 6.0
sampler_name: dpmpp_sde
scheduler : normal
denoise: 1.0

Load VAE:
vae_name kl-f8-anime2.ckpt



ControlNet Model1: control_openpose.safetensors
Image1: pose_present.png
Apply ControlNet: strength = 1

ControlNet Model2: control_scribble.safetensors
Image2: house_scribble.png
Apply ControlNet: strength = 0.8




Result example Multiple ControlNets and T2I-Adapters













Saturday, January 13, 2024

Ancient thai army by Bing Creators

 Ancient thai army by Bing Creators

ancient thai army by Bing Creators
ทัพไทยโบราณ by Bing Creators






Monday, December 25, 2023

ComfyUI T2I-Adapter vs ControlNets

 ComfyUI T2I-Adapter vs ControlNets

Model Check Point: V1-5pruned-emaonly.ckpt
ControlNetLoader: t2iadapter_depth-sd14v1.pth
ControlNetApply: strength : 1

Prompt
underwater photograph shark

Negative:
(hands), text error, cropped,(worst quality:1.2),(low quality:1.2), normal quality, (jpeg artifacts:1.3), signature, watermark, username, blurry, artist name, monochrome, sketch, censorship, censor, (copyright:1.2)

KSampler
Steps: 20
cfg 8
sampller_name: uni_pc_bh2
scheduler : normal
denoise : 1

EmptyLatentImage
width: 832
height : 384
batch_size:1




Example Result














 


Thursday, December 21, 2023

Comfy UI Example for Scribble ControlNet

 Comfy UI Scribble ControlNet

Model Checkpoint : Anything-V3.0.chkpt
Control net name : control_scribble.sfetensors
Vae : anythingKlF8Anime2VaeFtMse840000_klF8Anime2.safetensors

Prompt:
(solo) gril (flat chest:0.9), (fennec ears:1.1) (fox ears:1.1),
(blonde hair:1.0), messy hair, sky clouds, standing in a grass field,
(chibi), blue eyes

Negative Prompt:
(hands), text, error, cropped, (worst quality:1.2), (low quality:1.2),
normal quality, (jpeg artifacts:1.3), signature, watermark, username,
blurry, artist name, monochrome, sketch, censorship, censor, (copyright:1.2),
extra legs, (forehead mark) (depth of field) (emotionless) (penis)

KSampler
steps 16
cfg 6
Sampler name uni_pc

Empty Latent Image
width 512
height 512
batch size 1













 




Lady in moon night

 Lady in moon night







































































Domain