* * *

Author Topic: BGRABitmap tutorial  (Read 137785 times)

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #315 on: June 13, 2012, 04:49:08 pm »
New version of BGRABitmap (5.7.2).

- added PutImagePart to directly put only a rectangle of a bitmap
- added MergeBGRAWithGammaCorrection to merge two colors taking gamma correction into account
- fix for PutImage with dmSet mode and alpha <> 255
- added CopyRect(X,Y: Integer; SrcBitmap: TBGRACustomBitmap; SrcRect: TRect) in BGRACanvas
- compressable bitmap can now be streamed (read/write) and compression level can be set
- MakeBitmapCopy now accept system colors
- BGRALayers optimization for alpha = 0
- bug fix for QT implementation of drawing
- fix for conflicting case of rendering mode in BGRAScene3D (multishape+zbuffer is not possible)
- BGRASSE optimization
- bug fix for texture rendering with SSE
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #316 on: July 28, 2012, 10:26:29 pm »
Two news :

- New version 5.9 is compatible again with MacOS.
- Here is a tutorial on how to convert an application from TCanvas to TBGRACanvas : http://youtu.be/HGYSLgtYx-U
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #317 on: September 24, 2012, 05:04:30 pm »
New version of BGRABitmap 6.0

The big difference is better layer support and reading/writing of OpenRaster layered images. OpenRaster files can now also be loaded using standard LoadFromFile.

- pixelwise DrawLineAntialias with dashpos, and now DrawPolyLineAntialias looks nice with pixelwise dashes
- Compute ellipse, arc etc. with optional quality parameter (=1 by default meaning approximately one PointF per pixel)
-ComputeEllipse is deprecated, instead use ComputeEllipseBorder and ComputeEllipseContour
more precise and more optimized gradients
- filter emboss highlight with offset (only the portion containing the selection is computed)
- layers have now a unique id
- new layered bitmap functions : SetLayerBitmap, RotateCW, RotateCCW, HorizontalFlip, VerticalFlip, Resample, GetLayerIndexFromId, Duplicate, LayerUniqueId property
- OpenRaster can be loaded from a stream and provides an FPCustomImageReader

How to read an OpenRaster file :
Code: [Select]
uses BGRALayers;

var image: TBGRALayeredBitmap;
begin
  image := TBGRALayeredBitmap;
  image.LoadFromFile('someimage.ora');  //note that you can also load a Paint.NET file here
  ...
  image.Draw(Canvas, 0,0);
  ...
  image.Free;
end;

How to create an OpenRaster file :
Code: [Select]
var image: TBGRALayeredBitmap;
begin
  image := TBGRALayeredBitmap.Create(800,600);
  image.AddOwnedLayer(TBGRABitmap.Create(800,600));
  image.AddLayerFromFile('someimage.png');
  ...
  image.SaveToFile('myimage.ora');
  image.Free;
end;
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #318 on: September 24, 2012, 08:54:42 pm »
I've updated the tutorials.

The welcome page is http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial
It contains now a list of categories to help browse through the tutorials

It does not contain anymore the first tutorial, which is now at
http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_1

Please update the index for german and spanish version :)

Note : I also added sections in tutorials 4 and 5.
« Last Edit: September 24, 2012, 09:05:12 pm by circular »
Conscience is the debugger of the mind

lainz

  • Guest
Re: BGRABitmap tutorial
« Reply #319 on: September 25, 2012, 04:05:37 am »
Hi, attached slicescaling, it need your help Circular  ::)

ToDo:
- Fill top, left, right and bottom as texture
- Range check: if you set an invalid integer it just crash
- Things you want to change =)

Enjoy!

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #320 on: September 25, 2012, 04:14:43 pm »
Ok lainz, here is a modified version.

Now you can modify the margins after having created the object with :
Code: [Select]
    procedure SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    procedure SetMargins(AMargins: TMargins);
    property Margins: TMargins;

When you draw it, you need to specify the bounding rectangle :
Code: [Select]
    procedure Draw(ABitmap: TBGRABitmap; ARect: TRect; DrawGrid: boolean = False);
    procedure Draw(ABitmap: TBGRABitmap; ALeft,ATop,AWidth,AHeight: integer; DrawGrid: boolean = False);

After loading the bitmap and the margins, you can detect repeat optimizations :
Code: [Select]
    procedure AutodetectRepeat;

In your example, the center of the button can be repeated horizontally, avoiding much resampling. It's faster.

You can modify the repeat options with :
Code: [Select]
    property SliceRepeat[Aposition: TSliceRepeatPosition]: Boolean;
Conscience is the debugger of the mind

lainz

  • Guest
Re: BGRABitmap tutorial
« Reply #321 on: September 25, 2012, 05:03:26 pm »
Oh well this is really amazing  :'( Thanks  :D

You'll add this to BGRABitmap? Or I'll add it to BGRAControls.. as you wish.

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #322 on: September 25, 2012, 05:10:27 pm »
I hope you like it.  8-)

I don't know where it would be the best place. Probably in BGRAControls, because it's about drawing user controls, right? Or can we use it for something else?
Conscience is the debugger of the mind

lainz

  • Guest
Re: BGRABitmap tutorial
« Reply #323 on: September 26, 2012, 01:36:31 am »
Ok it's added in BGRAControls.

BTW if you can, add a filter for LazPaint for slice scaling layers.

it will help to create portrait borders for images and photos.

another exAmple: i'm usin 9slice to scale pseudo 3d chart bars in flash. it will be nice to have this in lazpaint, at least as filter..
« Last Edit: September 26, 2012, 07:06:03 am by lainz »

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: BGRABitmap tutorial
« Reply #324 on: September 26, 2012, 02:06:48 am »
The welcome page is http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial
It contains now a list of categories to help browse through the tutorials
also added sections in tutorials 4 and 5.

The category of this page is set to "Graphics/fr" -- probably should be just "Graphics".
Also, you may wish to add "Tutorials" category:
http://wiki.lazarus.freepascal.org/Category:Tutorials

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #325 on: September 26, 2012, 11:49:15 am »
Good idea.
Conscience is the debugger of the mind

lainz

  • Guest
Re: BGRABitmap tutorial
« Reply #326 on: September 28, 2012, 12:34:19 pm »
You can helpme with another thing?

It is a multi-9-slice-scaling (an array of bgraslicescaling).

The thing is that the most common used bitmaps has all the stages in the same bitmap distributed horizontal or vertical.

And it's a lazy thing to create each of them individualy from the same or separated bitmaps, there are some controls like checkbox that has 20 stages!

Attached images: Topaz button from AlphaSkins .asz (bmp with grayscale alpha and clFuchsia, i've converted it to png with LazPaint) and Windows 7 Button from the Aero .msstyles.

In bgrabitmapthemeutils i've used the vertical one, but if you can create both it will be nice =)

- It must set the same property for all the objects in the array (fill mode, resample mode, borders, etc..).
- So I can acces them SliceScalingArray[0].Draw(...);

 :-[

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #327 on: September 28, 2012, 03:13:35 pm »
Come on lainz, I'm sure you can do it.

Just create some class TBGRAMultiSlicescaling that you can create with an image, a number of items, and a direction, an that creates (as a private member) an array of TBGRASliceScaling. So you only have to updated those objects when properties are changed.

Finally, define a Draw function, with an additionnal parameter for the number of the item to be slicescaled.

I have confidence that you will do it nicely (and I am a bit tired today).
Conscience is the debugger of the mind

lainz

  • Guest
Re: BGRABitmap tutorial
« Reply #328 on: September 28, 2012, 07:49:39 pm »
I got it =)

Next I will add 'LoadFromFile' (INI) to speed up the process of creating a drawer.

Edit: added.
« Last Edit: September 28, 2012, 11:01:08 pm by lainz »

circular

  • Hero Member
  • *****
  • Posts: 1401
    • Personal webpage
Re: BGRABitmap tutorial
« Reply #329 on: September 29, 2012, 02:50:16 pm »
Great !  :)
Conscience is the debugger of the mind

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads