Recent

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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: New version of BGRABitmap
« Reply #45 on: April 15, 2015, 02:49:46 pm »
- average level tree (the unit AvgLvlTree is in LCL)
- reading DOM/XML (the units laz2_DOM, laz2_XMLRead, laz2_XMLWrite are in LCL)

All these are in lazutils for quite a while, which are parts that used to be LCL that are not LCL dependent.

So most logically, use lazutils package.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: New version of BGRABitmap
« Reply #46 on: April 15, 2015, 03:59:24 pm »
- to get a canvas to draw on a TfpgImage like on a window (this could be used to render text)
fpGUI's TfpgCanvas is not a TFPCustomCanvas descendant and doesn't surface the internal image buffer, so not all functionality is the same as FCL or LCL. Saying that, when I've needed that (probably twice in the last 10 years), I've used  TAggPas to attach to a TfpgImage, do my painting using the AggPas API. Alternatively, I've also used FPImgCanv from FCL, then convert the fpImage to a TfpgImage.

With the fpGUI redesign I'm busy with, where AggPas will become the default reference rendering engine and switching to a single window handle per form (not widget), this should be a lot easier. But the 'develop' branch is not there yet.

Quote
- to get an image from any canvas (not essential however)
Same as the above answer - as a work-around you could Canvas.Pixels[], but probably not the fastest workaround. ;)

Quote
- to draw data directly from data (opaque or transparent) : this can be achieved of course by creating an image
I've always used an image for this. You have direct access to the image data via the TfpgImage.ImageData and .ImageDataSize properties.

Quote
- to read an icon file (the type TIcon is in LCL)
Use FCL's FPImage and convert it to a TfpgImage - I saw no need to reinvent the wheel. See the fpg_imgfmt_png.pas unit for an example.

Quote
About UTF8 classes, it is ok as there as some functions in Free Pascal to do that.
Indeed, fpGUI has supported Unicode (UTF-8) for years without depending on LCL. ;-)  The fpg_utils.pas unit shows how fpGUI accomplishes file access - mostly via the fpgToOSEncoding() and fpgFromOSEncoding() functions.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #47 on: April 15, 2015, 06:00:30 pm »
- average level tree (the unit AvgLvlTree is in LCL)
- reading DOM/XML (the units laz2_DOM, laz2_XMLRead, laz2_XMLWrite are in LCL)

All these are in lazutils for quite a while, which are parts that used to be LCL that are not LCL dependent.

So most logically, use lazutils package.
Thanks. I will try that.

- to get a canvas to draw on a TfpgImage like on a window (this could be used to render text)
fpGUI's TfpgCanvas is not a TFPCustomCanvas descendant and doesn't surface the internal image buffer, so not all functionality is the same as FCL or LCL.
Yes but the operating system provides ways to draw on a window and to draw on a bitmap, so you could provide a TBitmap with a Canvas.

Quote
Quote
- to get an image from any canvas (not essential however)
Same as the above answer - as a work-around you could Canvas.Pixels[], but probably not the fastest workaround. ;)
Nope that would be too slow. So how to retrieve an image, a screenshot, etc. ?

Quote
Quote
- to draw data directly from data (opaque or transparent) : this can be achieved of course by creating an image
I've always used an image for this. You have direct access to the image data via the TfpgImage.ImageData and .ImageDataSize properties.
It is slower than a DIB section because creating the bitmap takes time. Also it seems that the image is always drawn as opaque.

Quote
Quote
- to read an icon file (the type TIcon is in LCL)
Use FCL's FPImage and convert it to a TfpgImage - I saw no need to reinvent the wheel. See the fpg_imgfmt_png.pas unit for an example.
Yes but I would like to provide support for ICO format.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #48 on: April 15, 2015, 09:54:45 pm »
Ok, so using LazUtils, I have AvgLvlTree, XML and some support for FreeType (only for ASCII chars, otherwise it is buggy). So that's kind of working.

Also with DIB section, it would be slightly faster.

Without transparency, only using a mask, there would be two different ways of drawing on a Canvas, either opaque or with 1-bit transparency.

Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #49 on: April 16, 2015, 12:59:44 am »
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit. It fixes also a type issue for FreeBSD.

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.3.zip/download

Here is an example project. First open the following packages: fpgui_toolkit, LazUtils and BGRABitmapPack4fpGui. Then copy "arial.ttf" file in the directory of the project. Finally open the project and run.
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: New version of BGRABitmap
« Reply #50 on: April 26, 2015, 10:29:26 am »
Hello,

I just attempted to upgrade BGRABitmap from 7.9.3 to 8.3.1 and am getting:

Code: [Select]
RunError(211)
I am using code like this:

Code: [Select]
t := TBGRABitmap.Create(fPbx.Width, fPbx.Height, bc); 
...
t.Draw(fPbx.Canvas, 0, 0, False);

to draw into the Canvas of a TPaintBox. It is triggered at this line:

Code: [Select]
function TBGRADefaultBitmap.GetBitmap: TBitmap;
begin
  if FAlphaCorrectionNeeded and CanvasAlphaCorrection then
    LoadFromBitmapIfNeeded;
  if FDataModified or (FBitmap = nil) then
  begin
    RebuildBitmap;
    FDataModified := False; // <-------------------
  end;
  Result := FBitmap;
end;

I'd appreciate any insight on why this is happening. Thanks!

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #51 on: April 26, 2015, 01:48:59 pm »
Oh I may have forgotten something.

Would it fix the problem to replace "BGRADefaultBitmap" by "BGRALCLBitmap", and "TBGRADefaultBitmap" by "TBGRALCLBitmap" in BGRABitmap.pas ?
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #52 on: April 27, 2015, 12:46:05 am »
Conscience is the debugger of the mind

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: New version of BGRABitmap
« Reply #53 on: April 27, 2015, 01:22:24 am »
Quote
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit.

Hello.

Wow, thanks for your demo LCL-fpGUI toolkit and BGRABitmap.  ;)

Hum, do you have plan for Pure-fpGUI toolkit and BGRABitmap ?

Pure fpGUI toolkit is autonomous and does not depend on LCL.
But BGRABitmap has LCL dependencies...

Many thanks.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #54 on: April 27, 2015, 01:25:40 am »
Nice wiki :)

It looks like the c# declarations for .net source files in visual studio.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #55 on: April 27, 2015, 01:51:21 am »
Quote
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit.

Hello.

Wow, thanks for your demo LCL-fpGUI toolkit and BGRABitmap.  ;)

Hum, do you have plan for Pure-fpGUI toolkit and BGRABitmap ?

Pure fpGUI toolkit is autonomous and does not depend on LCL.
But BGRABitmap has LCL dependencies...
No no, bgrabitmappack4fpgui does not depend on LCL. It depends on LazUtils, fpgui_toolkit and FCL. And fpgui_toolkit does not depend on LCL.

Nice wiki :)

It looks like the c# declarations for .net source files in visual studio.
Happy you find it nice :)
Conscience is the debugger of the mind

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: New version of BGRABitmap
« Reply #56 on: April 27, 2015, 02:00:26 am »
Quote
No no, bgrabitmappack4fpgui does not depend on LCL. It depends on LazUtils, fpgui_toolkit and FCL. And fpgui_toolkit does not depend on LCL.

Ha, perfect but... when trying to compile your fpGUI demo i get that error message =>

BGRABitmapPack4fpGUI needs =>
LazUtils => here error with => Not Found !
fpGUI_toolKit

?

And i cannot compile it...
« Last Edit: April 27, 2015, 02:13:02 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: New version of BGRABitmap
« Reply #57 on: April 27, 2015, 02:26:58 am »
Try the following: in Lazarus, open the packages LazUtils and fpGUI_toolkit, then open BGRABitmapPack4fpGui. Can you compile it then ?
Conscience is the debugger of the mind

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: New version of BGRABitmap
« Reply #58 on: April 27, 2015, 02:35:29 am »
Hello and thanks to answer.

I have installed LazUtils from Lazarus 1.2.6.

Now at compil i get that error message :

Quote
paswstring.pas(379,43) Error: Incompatible types: got "<address of procedure(PWideChar;var AnsiString;Int64);Register>" expected "TUnicodeStringManager.<procedure variable type of procedure(PWideChar;var RawByteString;Word;Int64);Register>"

Maybe it is because i use last fpc 3.0.1 ?

Is LazUtils absolutely necessary, does it not exist something else more flexible  ?
« Last Edit: April 27, 2015, 02:37:06 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: New version of BGRABitmap
« Reply #59 on: April 27, 2015, 02:51:22 am »
Quote
Maybe it is because i use last fpc 3.0.1 ?

Yep, with fpc 2.4 it works  ;)

Huh, Circular, what a perfect work you have done.  ;D

It works perfectly and it is pure-fpGUI => incredible.   :o

Where are you with your plan to do a BGRABitmap library ?
If you agree, it will be a pleasure to help you for that.

I am totally impressed  :-X

Hum, the top of the top will be if BGRABitmap was free of LazUtils package. (I never was able to create libraries with LCL dependencies)

Many, many thanks.

Fre;D

PS: In attachment arial.ttf needed for your demo  ;)

« Last Edit: April 27, 2015, 03:50:37 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018