### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Recent

#### user5

• Sr. Member
• Posts: 274
« on: February 06, 2019, 05:53:38 pm »
I have several questions about the code below.
1. What is the term "fpictureON"?
2. What type of variable should "hue" be and what is its acceptable range?
The code runs but it only produces a black image. Thanks.

Code: Pascal  [Select][+][-]
1. procedure TForm1.Button4Click(Sender: TObject);
2. var
3.   t: TLazIntfImage;
4.   mybitmap:TBitmap;
5.   newcolor:TColor;
6.   px,py : integer;
7.   CurFPColor: TFPColor;
8.   r,g,b,h,l,s : byte;
9.   alpha : word;
10.   hue:integer;
11.   filename:string;
12.   mypicture:TPicture;
13. begin
14.
15.  if opendialog1.execute = true then
16.   begin
17.    mypicture := TPicture.create;
18.    mybitmap := TBitmap.create;
19.    filename := opendialog1.FileName;
20.    hue := 128;
21.    try
24.     image3.width := mypicture.width;
25.     image3.height := mypicture.height;
26.     image4.width := image3.width;
27.     image4.height := image3.height;
28.     //t :=  fpictureON.Bitmap.CreateIntfImage;
29.     t:=TLazIntfImage.Create(0,0);
31.
32.     t.width := image3.width;
33.     t.height := image3.height;
34.     for py:=0 to image3.Height-1 do begin
35.     for px:=0 to image3.Width-1 do begin
36.     CurFPColor := t.Colors[px,py];
37.     newcolor := image3.canvas.pixels[px,py];
38.     RGBtoHLS(hi(curFPColor.red),hi(curFPColor.green),hi(curFPColor.blue),h,l,s);
39.     HLStoRGB(hue,l,s,r,g,b);
40.     curFPColor.red := r shl 8;
41.     curFPColor.green := g shl 8;
42.     curFPColor.blue := b shl 8;
43.     t.Colors[px,py] :=  curFPColor;
44.    end;
45.    end;
46.
47.     t.savetofile('C:\Users\Arthur\Desktop\temp11\new1.bmp');
48.     application.processmessages;
50.    finally
51.      t.free;
52.    end;
53.    mybitmap.free;
54.    mypicture.free;
55.   end;

#### Blaazen

• Hero Member
• Posts: 2920
• POKE 54296,15
« Reply #1 on: February 06, 2019, 06:43:26 pm »
1) Probably some public or protected field:
Code: Pascal  [Select][+][-]
1. fpictureON: TPicture;
2) You have to look to code of HLSToRGB (I don't know what library it is). The range can be 0..100 or rather 0..255 since it is byte.
Lazarus 2.1.0 r63881 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

• Hero Member
• Posts: 2513