Recent

Author Topic: BGRA Contest  (Read 66372 times)

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: BGRA Contest
« Reply #45 on: July 26, 2015, 07:18:09 pm »
Well you did a very good job, it is not going to be easy.

But anyway, I am very happy that your demos are great.  :)

And mine will be too!  8-)
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #46 on: July 26, 2015, 07:25:17 pm »
Well you did a very good job, it is not going to be easy.

But anyway, I am very happy that your demos are great.  :)

And mine will be too!  8-)
Dont let it for the late,so maybe we got time to try again :D

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: BGRA Contest
« Reply #47 on: July 26, 2015, 08:32:28 pm »
kewl use of 'media-style controls' aradeonas.

i could see this as being - sort of - a desktop screen saver, if you had the program reading a users media folder.
but then there *could* be a copyright issue...
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #48 on: July 26, 2015, 08:37:35 pm »
Thanks.But why?

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: BGRA Contest
« Reply #49 on: July 26, 2015, 10:12:11 pm »
@aradeonas: Nice... I would love to use this in XiXMusicPlayer (http://www.xixmusicplayer.org)

I already have a Fullscreen MediaMode, but it would be nice to create some plugin support, so extras like this can be added on the fly instead of hardcoded in the XiX Source code. :D
Be the difference that makes a difference

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #50 on: July 26, 2015, 10:25:20 pm »
@aradeonas: Nice... I would love to use this in XiXMusicPlayer (http://www.xixmusicplayer.org)

I already have a Fullscreen MediaMode, but it would be nice to create some plugin support, so extras like this can be added on the fly instead of hardcoded in the XiX Source code. :D
Thank you.I will be more than happy.
If you want any help just tell me,also if you add this in the project.

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: BGRA Contest
« Reply #51 on: July 27, 2015, 06:17:41 am »
@aradeonas: Nice... I would love to use this in XiXMusicPlayer (http://www.xixmusicplayer.org)

I already have a Fullscreen MediaMode, but it would be nice to create some plugin support, so extras like this can be added on the fly instead of hardcoded in the XiX Source code. :D

I suggest you to use .dll or will be a hell trying to implement everything needed with scripting like pascal script or la-pe (bgra is working more with la-pe, but I don't know what's the current implementation status...). pascal script is slow and it does not support the necessary stuff to do it.

Like calling predefined functions passing canvas as parameter for example, to draw each element needed. Its a very tiny start :)

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: BGRA Contest
« Reply #52 on: July 28, 2015, 01:45:01 am »
I have your plugin working ;)

Well..

This is an example and only works under Windows.

This is the DLL that implements "DrawSomething" that receives a TCanvas where to draw. Use of bgrabitmap is optional, but I choose to use it.
Code: [Select]
library project1;

{$mode objfpc}{$H+}

uses
  Classes, BGRAGraphics, BGRABitmap, BGRABitmapTypes, Math;

procedure DrawSomething(ACanvas: TCanvas); stdcall;
var
  bmp: TBGRABitmap;
begin
  bmp := TBGRABitmap.Create(ACanvas.Width, ACanvas.Height);
  bmp.Rectangle(Random(10), Random(10), RandomRange(10, 50), RandomRange(10, 50), BGRABlack, BGRAWhite, dmSet);
  bmp.Draw(ACanvas, 0, 0);
  bmp.Free;
end;

exports
  DrawSomething;

begin
end.


This is the Form that uses the DLL (it does not requires to be compiled BGRABitmap to work).

The DLL must be in the folder 'plugins' and it must be named 'project1.dll'. Of course you can imagine how to have a lot of dll in that folder and load just the one that you choose.

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Windows;

type

  TDrawSomething = procedure (ACanvas: TCanvas); stdcall;

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    MyLib: HINST;
    DrawSomething: TDrawSomething;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

function GetPlugin: string;
begin
  result := ExtractFilePath(ParamStr(0)) + 'plugins\project1.dll';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MyLib := LoadLibrary(PChar(GetPlugin));

  if MyLib = 0 then
    ShowMessage('Error loading library.')
  else
    DrawSomething := TDrawSomething(GetProcAddress(MyLib, PChar('DrawSomething')));

  if DrawSomething <> nil then
  begin
    ShowMessage('Library loaded.');
  end
  else
  begin
    ShowMessage('Error loading procedure.');
    Application.Terminate;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  if FreeLibrary(MyLib) then
    ShowMessage('Library freed.');
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  if DrawSomething = nil then
    exit;

  DrawSomething(Canvas);
end;

end.
         

The code I've done according to this website: http://www.informit.com/articles/article.aspx?p=27837&seqNum=3

It can be done better.

There is a cross platform way of doing this?

Well, at least you have an option for your media player!

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: BGRA Contest
« Reply #53 on: July 28, 2015, 02:24:25 am »
Thanks.But why?

why? - as a 'sort of' screen saver?

or

why? - as copyright issue?

i just tend to be conservative/careful... if the user didn't have album cover images already downloaded, could be an issue having code to do so... i don't know...

anyway, it may be that you wrote the proggy only for the contest... you can safely ignore my copyright comments... :)
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #54 on: July 28, 2015, 08:18:06 am »
Thank you Lainz , its a good demo.
BitBangerUSA I meant copyright and no it will not a problem because its only a demo and also in real program it should get covers from music files but thank you for notice.

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: BGRA Contest
« Reply #55 on: July 28, 2015, 08:56:48 pm »
Incorporated aradeonas his work in XiX Music Player:  https://youtu.be/DYpDzOzGI6w

It is still a bit slow and a few things like an active 'shuffle' button and three states for the repeat button needs to be added.
Next up is trying to put this in plugins.
Be the difference that makes a difference

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #56 on: July 28, 2015, 09:05:10 pm »
Very good.
If you want my help give me a way or source and I will work on it.
In the video there is a delay in mouse hover on buttons,why?
« Last Edit: July 28, 2015, 09:17:51 pm by aradeonas »

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: BGRA Contest
« Reply #57 on: July 28, 2015, 11:03:35 pm »
@aradeonas:
My guess it that it is MacOS related.  The compiled source of your demo does the same when pictures are found.  Without pictures it is faster.  I already did the changes circular posted.  I need to test it in Linux and Windows.
Another problem is that when used in XiX only one (sometimes two) tiles animate.  It is always the same tile that animates, while in the source demo, the tiles change.
A nice trick would be that the tiles under the mouse pointer hover up, and clicking the cover plays the album.  When the album gets played, the place of the tile gets taken by another album cover.  %)

Any help is welcome.  Do you have a Sourceforge account?  I can add you to the SVN list.
Latest SVN commit does not yet have the CD Cover Browser (still needs to be polished) and does not yet contain your added demo.

I will put up a link with the latest changes too.

« Last Edit: July 28, 2015, 11:07:44 pm by Zittergie »
Be the difference that makes a difference

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: BGRA Contest
« Reply #58 on: July 28, 2015, 11:45:39 pm »
@aradeonas, @Zittergie:

You can use the unit "dynlibs" instead of "Windows" in order to do the plugin loading cross platform. Everything should work on the example provided, except for this line:
Code: [Select]
    MyLib: HINST; 
That you must replace with:
Code: [Select]
    MyLib: TLibHandle; 
And must be working in all major platforms.

Also check if instead of "stdcall" you must use "cdcall" under Linux and Mac both in the dynamic library .dll / .so / .dylib and in the project itself. (Try using ifdefs to get it in blocks).

For example in the bgrabitmap.dll we're using:
Code: [Select]
{$IFDEF windows}stdcall;{$ELSE}cdecl;{$ENDIF}
Edit: Of course maybe you already know all of this, I'm so intrigued to do my own plugin ;) Like the old Winamp and Windows Media Player ones!
« Last Edit: July 29, 2015, 12:49:45 am by lainz#007 »

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: BGRA Contest
« Reply #59 on: July 29, 2015, 07:34:04 am »
Zittergien ,yes I have,my username here is also in sf.
Lainz: thank you I should check this out ;)

 

TinyPortal © 2005-2018