Recent

Author Topic: New version of BGRABitmap  (Read 285445 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: New version of BGRABitmap
« Reply #15 on: July 25, 2014, 12:52:31 am »
- Text hint / placeholder on all platforms (Qt, Gtk, Windows). This is a hint which is showed when edit text is empty. Normally only Gtk (ver 3+) and Qt has it, but due that windows edit doesn't, LCL is not publishing this property
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: New version of BGRABitmap
« Reply #16 on: July 25, 2014, 09:50:50 am »
- Text hint / placeholder on all platforms (Qt, Gtk, Windows). This is a hint which is showed when edit text is empty. Normally only Gtk (ver 3+) and Qt has it, but due that windows edit doesn't, LCL is not publishing this property
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx
My mistake. It is on windows and Qt but not on Gtk2 (added in Gtk3). I made a mistake with button in tabsheets (available on Gtk and Qt but not on Windows)

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #17 on: July 25, 2014, 03:21:12 pm »
BGRABitmap uses the underlying OS to produce fonts. However it tries to look the same on all platforms. You can have a try simply in a window, to draw text, measure it, etc. and if you find it give acceptable results for you, then it is ok. If there are differences between OS's, I would be happy to know about it.
Conscience is the debugger of the mind

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: New version of BGRABitmap
« Reply #18 on: July 25, 2014, 04:42:32 pm »
My mistake. It is on windows and Qt but not on Gtk2 (added in Gtk3).

Dumn! I was hopping that the next release would have this feature surfaced, now we have to wait for a stable release of gtk3. Oh well.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #19 on: August 07, 2014, 05:53:29 pm »
Here is a new version of BGRABitmap (7.7) for a quick fix of a bug in 3d rendering. You don't need to update now unless you work with 3d models with shading.

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.7.zip/download

Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #20 on: September 21, 2014, 08:04:32 pm »
New version of BGRABitmap ( 7.8 )

- can read MioMap BMP files (files start with RL instead of BM)
- function to define a rectangle not with right/bottom but with width/height
Code: [Select]
function RectWithSize(left,top,width,height: integer): TRect;- GDK offset fix (Linux)
- fast blur with large radius fix
- PNG grayscale+alpha 16 bit fix

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.8.zip/download
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #21 on: October 11, 2014, 01:55:54 pm »
New version of BGRABitmap (7.9)
http://sourceforge.net/projects/lazpaint/files/src/

Fixes:
- fixes for GIF on big endian machines
- fix for TBGRACanvas.Rectangle function with Filled:=False
- fix for ArcStartPoint function

Added:
- added support for arrows
- added function ComputeArc(const arc: TArcDef; quality: single): ArrayOfTPointF;

Example for arrows:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes;

{ TForm1 }

procedure TForm1.FormPaint(Sender: TObject);
const w=9;
var bmp:TBGRABitmap;
begin
  bmp := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRAWhite);

  bmp.ArrowStartAsTail;
  bmp.ArrowStartRepeat := 2;
  bmp.ArrowEndAsTriangle(0.25,False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(80,80),PointF(ClientWidth-160,ClientHeight div 2),PointF(ClientWidth-80,ClientHeight-20)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.ArrowStartRepeat := 1; //restore default value

  bmp.ArrowStartAsClassic(True,True,3);
  bmp.ArrowStartOffset := -8;
  bmp.ArrowEndAsClassic(False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(40,60),PointF(ClientWidth div 3,20),PointF(ClientWidth-80,40)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.ArrowStartOffset := 0; //restore default value

  bmp.ArrowStartAsClassic(True,True);
  bmp.ArrowStartSize := PointF(1,2);
  bmp.ArrowStartOffset := -5.5;
  bmp.ArrowStartRepeat := 3;
  bmp.ArrowEndAsTriangle(0.75);
  bmp.DrawLineAntialias(20,90, 80,ClientHeight-40,
    BGRABlack,w);
  bmp.ArrowStartSize := PointF(2,2); //restore default values
  bmp.ArrowStartOffset := 0;
  bmp.ArrowStartRepeat := 1;

  bmp.ArrowStartAsClassic;
  bmp.ArrowEndAsClassic(False,False,2);
  bmp.DrawLineAntialias(ClientWidth-40,40,ClientWidth-40,ClientHeight-80,BGRABlack,w);

  bmp.Draw(Canvas,0,0);
  bmp.Free;
end;

To define an arrow, use ArrowStartAs... and ArrowEndAs...

Some properties are there to customise the head/tail:
- ArrowStartRepeat is the number of repetition of the arrow head/tail. The default value is 1.
- ArrowStartOffset is the offset of the head/tail relative to the start of the line, one unit being equal to the width of the line. The default value is 0.
- ArrowStartSize is the size of the arrow head, one unit being equal to the width of the line. The default value is PointF(2,2)

ArrowEnd... and ArrowStart... are the same except ArrowEnd is relative to the end of the line

The arrows are applied to DrawLineAntialias and DrawPolyLineAntialias functions
« Last Edit: October 11, 2014, 02:04:58 pm by circular »
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #22 on: October 12, 2014, 06:40:49 pm »
Here is a version 7.9.2. It is a quick fix for arrows. It also solves one problem with multipolygon filling.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.9.2.zip/download
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #23 on: November 06, 2014, 11:32:28 am »
Here is version 7.9.3. It fixes bezier curves in Canvas2d and improves speed on Linux for text rendering.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.9.3.zip/download
Conscience is the debugger of the mind

Xirax

  • New Member
  • *
  • Posts: 34
Re: New version of BGRABitmap
« Reply #24 on: February 27, 2015, 02:42:50 am »
For any one interest to BGRABitmap its good to take a look at Jimi:
http://forum.lazarus.freepascal.org/index.php/topic,27524.0.html

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #25 on: March 12, 2015, 07:24:09 pm »
Thanks for the link Xirax.

Here is a new version of BGRABitmap 8.0.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.0.zip/download

Box blur
A very fast blur is available. It is "box blur", where the area around a pixel is blurred as a square. You can use it with:

- text effects (set ShadowQuality:= rbBox)
- FilterBlurRadial (use rbBox as blur type)
- Canvas2d (set shadowFastest:= true)

3d rendering
It is essentially an upgrade to support more OBJ files :
- it is possible now to define custom normals
- negative vertex reference has been added
- loading materials from MTL file (using LoadMaterialsFromFileUTF8 function)

Often, the material file has the same name as the object file, so you can get the correct filename:
Code: [Select]
materialFilename := ChangeFileExt(objectFilename,'.mtl')
Color quantization
This goes with new classes to handle palettes. In BGRAPalette unit, there are different kind of palettes. The types you are likely to create are :
- TBGRAPalette: a palette where you can add and remove colors
- TBGRAWeightedPalette: a palette where each color has a weight. So if you add the same color multiple times, its weight increases

In order to reduce the number of colors or to save a bitmap to a file with a small number of colors, the class TBGRAColorQuantizer is available BGRAColorQuantization unit.

First instantiate TBGRAColorQuantizer with a bitmap or a palette. It will procude a reduced palette. The maximum number of color in this palette is defined by the property ReductionColorCount (by default 256). There are different ways to handle transparency, indicated by TAlphaChannelPaletteOption :
- acIgnore: it means alpha channel is considered separately from the color
- acTransparentEntry: it means that one entry in the palette will be the transparent color, with alpha = 0
- acFullChannelInPalette: it means that there will be if necessary a gradient of alpha values represented in the palette (this is recommended for example if you save in PNG format)

Here is for example how you would produce a 256 color PNG file:
Code: [Select]
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
  quant : TBGRAColorQuantizer;
  sourceBmp: TBGRABitmap;
begin
  sourceBmp := TBGRABitmap.Create('picture_in_32_bits.bmp');
  quant := TBGRAColorQuantizer.Create(sourceBmp, acFullChannelInPalette);
  quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_8_bits.png');
  quant.Free;
  sourceBmp.Free;
end;

Here is for example how you would produce a 16 color BMP file:
Code: [Select]
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
  quant : TBGRAColorQuantizer;
  sourceBmp: TBGRABitmap;
begin
  sourceBmp := TBGRABitmap.Create('picture.jpg');
  quant := TBGRAColorQuantizer.Create(sourceBmp, acIgnore);
  quant.ReductionColorCount := 16;
  quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_4_bits.bmp');
  quant.Free;
  sourceBmp.Free;
end;
« Last Edit: March 12, 2015, 07:30:51 pm by circular »
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: New version of BGRABitmap
« Reply #26 on: March 22, 2015, 04:30:19 pm »
Thank you very much circular.
Its good to see a new version specially Blure.
@circular is there any roadmap for BGRA and its control?
« Last Edit: March 22, 2015, 04:42:17 pm by aradeonas »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #27 on: March 22, 2015, 07:43:21 pm »
Indeed box blur is pretty fast.  :)

For BGRABitmap itself, there is not much on the todo list. There are possible improvements in different areas : SVG format, GIF format, font handling, grayscale bitmap stored in memory, more file formats. However none of those are essential nor have I received any request in that direction, except one minor request for line spacing with text rendering.

For LazPaint, I am adding new features and hope to release a new version soon.

I wrote LZP file format reference there:
http://wiki.freepascal.org/LazPaint_LZP_Format

Regarding controls, the simplest would be to see with 007 on BGRA Control thread. He is doing a great job maintaining the package.
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: New version of BGRABitmap
« Reply #28 on: March 22, 2015, 07:52:01 pm »
Thanks but I have request for you ;)
If we have more vector tools like SVG format and adding them to Canvas2D it will be great.I like vector UI very much.
Also a big thing that I think BGRABitmap need is documentation and more demos maybe because for someone like me is hard to learn and all I learned is from demos that you made in old BGRABitmap topics and demos in old LazPaint package.Also a new home like a website will be good.
Because when I talk to developers most of them don't know BGRABitmap is exists and one of my reason in working with Lazarus is BGRABitmap so more people know it more request come ;)
PS,tutorial is not enough for this beautiful world.
« Last Edit: March 22, 2015, 07:58:56 pm by aradeonas »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: New version of BGRABitmap
« Reply #29 on: March 22, 2015, 09:17:12 pm »
Well I would appreciate some help writing the documentation.

I take a note of your request for more SVG and Canvas2d.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018