Recent

Author Topic: BGRA: Displaying BGRABitMap in Virtual screen  (Read 3108 times)

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
BGRA: Displaying BGRABitMap in Virtual screen
« on: July 15, 2021, 02:35:51 pm »
In
procedure TForm1.VirtualScreenRedraw(Sender: TObject; Bitmap: TBGRABitmap);

How do I display a bitmap loaded from a file or drawn in another TBGRABitmap?

Bitmap.EllipseAntialias(Swimmer_Images[A].Left,
           TopOffset + A*LaneHeight + LaneHeight Div 2,
           10, 10, BGRABlack, 1, Swimmer_Images[A].SColor);
works fine - taken from the balls example from the virtualscreen demo.

I miss Bitmap.DrawBitmap(bitmap.BGRABitMap,x,y,true) ?


mosquito

  • Full Member
  • ***
  • Posts: 141
Re: BGRA: Displaying BGRABitMap in Virtual screen
« Reply #1 on: July 15, 2021, 04:54:35 pm »
this work for me... button1 load image and put in memory. button2 put image from memory to virtualscreen.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BCTypes, BGRABITMAPTYPES;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     Button1: TButton;
  18.     Button2: TButton;
  19.     Memo1: TMemo;
  20.     procedure BGRAVirtualScreen1Exit(Sender: TObject);
  21.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  22.     procedure Button1Click(Sender: TObject);
  23.     procedure Button2Click(Sender: TObject);
  24.   private
  25.  
  26.   public
  27.   BMP1 : TBGRABITMAP ;
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.lfm}
  36.  
  37. { TForm1 }
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. begin
  41.   if FileExists('sample.png') then begin
  42.     BMP1 := TBGRABITMAP.CREATE('sample.png');
  43.     MEMO1.CLEAR;
  44.     MEMO1.Lines.Add('sample.png loaded');
  45.  
  46.   end else begin
  47.     showmessage('sample.png not in path');
  48.   end;
  49. end;
  50.  
  51. procedure TForm1.Button2Click(Sender: TObject);
  52. begin
  53.   BGRAVirtualScreen1.RedrawBitmap;
  54. end;
  55.  
  56. procedure TForm1.BGRAVirtualScreen1Exit(Sender: TObject);
  57. begin
  58. BMP1.FREE;
  59. end;
  60.  
  61. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  62. begin
  63. BITMAP.PUTIMAGE(0,0,BMP1,dmset,255);
  64.  
  65. end;
  66.  
  67. end.
  68.  
  69.  
« Last Edit: July 15, 2021, 04:58:27 pm by mosquito »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: BGRA: Displaying BGRABitMap in Virtual screen
« Reply #2 on: July 15, 2021, 04:57:06 pm »
Hi!

The VirtualScreen owns a BGRAbitmap.

For drawing from one BGRAbitmap to another you use:

Code: Pascal  [Select][+][-]
  1. MainBGRAbitmap.putImage (x,y, SourceBGRAbitmap, TDrawMode);
  2.  
where TDrawMode is defined in bgrapixel.inc as:
Code: Pascal  [Select][+][-]
  1.  
  2. TDrawMode = (
  3.     {** The pixel is replaced }
  4.     dmSet,
  5.     {** The pixel is replaced if the pixel over has an alpha value of 255 }
  6.     dmSetExceptTransparent,
  7.     {** The pixel is blend over the other one according to alpha values,
  8.         however no gamma correction is applied. In other words, the color
  9.         space is assumed to be linear }
  10.     dmLinearBlend,
  11.     {** The pixel is blend over the other one according to alpha values,
  12.         and a gamma correction is applied. In other word, the color
  13.         space is assumed to be sRGB }
  14.     dmDrawWithTransparency,
  15.     {** Values of all channels are combined with Xor. This is useful to
  16.         compute the binary difference, however it is not something that makes
  17.         much sense to display on the screen }
  18.     dmXor);
  19.  


Winni

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
Re: BGRA: Displaying BGRABitMap in Virtual screen
« Reply #3 on: July 15, 2021, 10:02:33 pm »
 ;) Thank you both - just what I was looking for. It works perfectly :-[

 

TinyPortal © 2005-2018