### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: TImage manipulatione  (Read 4871 times)

#### xinyiman

• Hero Member
• Posts: 2092
##### TImage manipulatione
« on: July 28, 2016, 11:52:16 am »
hello guys, a question. There is a native library lazarus or who is cross-platform and has no external dependencies for manipulating picture contained in a TImage? I mainly serve

rotation
contrast
brightness
zoom

thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

#### simin_sh

• Full Member
• Posts: 143
##### Re: TImage manipulatione
« Reply #1 on: July 28, 2016, 03:08:26 pm »
Did you test BGRABitmap? You can edit the bitmap and then assign it into the TImage.
OS Windows 10 - Lazarus 1.7 - FPC 3.1.1

#### xinyiman

• Hero Member
• Posts: 2092
##### Re: TImage manipulatione
« Reply #2 on: July 28, 2016, 03:20:11 pm »
No, you have some examples to the functions I mentioned above?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

#### lainz

• Hero Member
• Posts: 3711
• Leandro Diaz
##### Re: TImage manipulatione
« Reply #3 on: July 28, 2016, 05:55:39 pm »
BGRABitmap Rotate:

Code: Pascal  [Select][+][-]
1.   Bitmap.RotateCCW;
2.   Bitmap.RotateCW;
3.   VerticalFlip(ARect: TRect);
4.   HorizontalFlip(ARect: TRect);
5.

Zoom:

Code: Pascal  [Select][+][-]
1. Resample(newWidth, newHeight: integer;
2.       mode: TResampleMode = rmFineResample): TBGRACustomBitmap;

You can access the pixels this way to apply any filter you want:

Code: Pascal  [Select][+][-]
1. // all pixels //
2. var
3.   i: integer;
4.   p: PBGRAPixel;
5. begin
6.   p := Bitmap.Data;
7.
8.   for i := Bitmap.NBPixels-1 downto 0 do
9.   begin
10.     p^.red := ;
11.     p^.green := ;
12.     p^.blue := ;
13.     p^.alpha := ;
14.     Inc(p);
15.   end;

Code: Pascal  [Select][+][-]
1. // scan line //
2. var
3.   x, y: integer;
4.   p: PBGRAPixel;
5. begin
6.   for y := 0 to Bitmap.Height - 1 do
7.   begin
8.     p := Bitmap.Scanline[y];
9.     for x := 0 to Bitmap.Width - 1 do
10.     begin
11.       p^.red := ;
12.       p^.green := ;
13.       p^.blue := ;
14.       p^.alpha := ;
15.       Inc(p);
16.     end;
17.   end;
18.   Bitmap.InvalidateBitmap;

#### xinyiman

• Hero Member
• Posts: 2092
##### Re: TImage manipulatione
« Reply #4 on: July 28, 2016, 06:25:36 pm »
But BGRABitmap run on Mac OSX?!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

#### lainz

• Hero Member
• Posts: 3711
• Leandro Diaz
##### Re: TImage manipulatione
« Reply #5 on: July 28, 2016, 07:01:20 pm »
But BGRABitmap run on Mac OSX?!

Yes

Quote
bgrabitmap.pas
--------------
Free easy-to-use memory bitmap 32-bit,
8-bit for each channel, transparency.
Channels can be in the following orders:
- B G R A (recommended for Windows, required for fpGUI)
- R G B A (recommended for Gtk and MacOS

#### xinyiman

• Hero Member
• Posts: 2092
##### Re: TImage manipulatione
« Reply #6 on: July 28, 2016, 10:43:56 pm »
Ok, it works on window. Then in the next few days I try on linux and mac. Now I wanted to understand how to manage the brightness and contrast of the image.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

#### xinyiman

• Hero Member
• Posts: 2092
##### Re: TImage manipulatione
« Reply #7 on: July 28, 2016, 10:56:41 pm »
on linux I have the following problem when you compile the source. Why? How do you solve?

Code: Pascal  [Select][+][-]
1. function TBGRASVG.GetViewBox(AUnit: TCSSUnit): TSVGViewBox;
2. begin
3.   with ViewBox do
4.   begin
5.     result.min := FUnits.ConvertCoord(min,cuCustom,AUnit);
6.     result.size := FUnits.ConvertCoord(size,cuCustom,AUnit);
7.   end;
8. end;
9.

Messaggi, avvertimenti: 1
Warning: other unit files search path (aka unit path) of "project1" contains "/home/francesco/Documenti/Lazarus_Componenti/bgrabitmap9.1", which belongs to package "BGRABitmapPack"
Compile package BGRABitmapPack 9.1: Codice di uscita 256, Errori: 1
bgrasvg.pas(346,8) Error: Internal error 2012090607
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

#### lainz

• Hero Member
• Posts: 3711
• Leandro Diaz
##### Re: TImage manipulatione
« Reply #8 on: July 28, 2016, 11:39:48 pm »
I dont know. Try reporting it in the bgrabitmap subforum.

#### circular

• Hero Member
• Posts: 3451
##### Re: TImage manipulatione
« Reply #9 on: July 29, 2016, 04:13:20 pm »
« Last Edit: July 29, 2016, 04:16:07 pm by circular »
Conscience is the debugger of the mind