Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-07-24 Thread James Richters

>I am also wondering if it would be beneficial to accelerate other procedures 
>in the same way especially getimage()

I went ahead and tried it and I've got getimage() to about 18x faster on my 
system.  I changed how it works a little, the original was checking every 
single pixel if it was in the viewport or not, instead of doing that, I just 
fixed the nested loop to only operate within the range included in the 
viewport.  I also added a section to only include items that are actually on 
the screen as well.  I've updated my github repository, the changes I've made 
are on the 'zaaphod_custom' branch.  Here's a link

https://github.com/Zaaphod/ptcpas/blob/Zaaphod_Custom/ptcgraph/ptcgraph.pp
 

I'm wondering if I should take the default procedures out of graph.inc and 
replace them with just an error and halt as many of the other procedures have 
done.

I thought I would include the i386-win32 and x86_64-win64 compiled units of 
ptcpas with the accelerated versions of putimage() and getimage() in my 
repository if anyone wants to give them a try.   They are in a 'units' 
directory on the 'compiled' branch Here's the link:

https://github.com/Zaaphod/ptcpas/commit/b96f7208f079d4e2fe208ba5ac464f8f6808d79b

https://github.com/Zaaphod/ptcpas/tree/Compiled


James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-07-20 Thread james
I've been having very good results with the accelerated putimage() in ptcgraph. 
   I am wondering if this modification could be added to 3.04, or some future 
release,  as I think everyone would want putimage() to happen as fast as 
possible.I can't figure out how or where to submit this though.   I got the 
original code from here: https://sourceforge.net/p/ptcpas/code/785/tree/trunk/  
and  the code modified code I have is here: 
https://github.com/Zaaphod/ptcpas/tree/Avoid_ReChecking_Bitblt.   I don't see 
any method to submit something similar to a pull request though.   Is there 
some method to contribute code to the PTCPAS project?  

I am also wondering if it would be beneficial to accelerate other procedures in 
the same way especially getimage()   I'm wanting to make it appear as it an 
object moves across the screen so I want to getimage() a small portion of the 
screen, copy the image variable, draw the object in the copy, putimage() the 
copy to show the object, then when it's time to move it, putimage() the 
original back, then start the process over again in the next location.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-07-04 Thread James Richters
I defined a static array to convert the mode 13h VGA palette to separate red, 
green and blue to send to aggpas as well as the packed RGB565 format needed to 
send to ptcgraph 16bit colors.

 

James

 

 

Type 

   VGARGBRec= Record

  R,G,B:Byte;

  RGB:Word;

   end;

 

Const

   VGA256: Array[0..255] of VGARGBRec = (

  (R:$00; G:$00; B:$00; RGB:$),

  (R:$00; G:$00; B:$AA; RGB:$0015),

  (R:$00; G:$AA; B:$00; RGB:$0540),

  (R:$00; G:$AA; B:$AA; RGB:$0555),

  (R:$AA; G:$00; B:$00; RGB:$A800),

  (R:$AA; G:$00; B:$AA; RGB:$A815),

  (R:$AA; G:$55; B:$00; RGB:$AAA0),

  (R:$AA; G:$AA; B:$AA; RGB:$AD55),

  (R:$55; G:$55; B:$55; RGB:$52AA),

  (R:$55; G:$55; B:$FF; RGB:$52BF),

  (R:$55; G:$FF; B:$55; RGB:$57EA),

  (R:$55; G:$FF; B:$FF; RGB:$57FF),

  (R:$FF; G:$55; B:$55; RGB:$FAAA),

  (R:$FF; G:$55; B:$FF; RGB:$FABF),

  (R:$FF; G:$FF; B:$55; RGB:$FFEA),

  (R:$FF; G:$FF; B:$FF; RGB:$),

  (R:$00; G:$00; B:$00; RGB:$),

  (R:$14; G:$14; B:$14; RGB:$10A2),

  (R:$20; G:$20; B:$20; RGB:$2104),

  (R:$2C; G:$2C; B:$2C; RGB:$2965),

  (R:$38; G:$38; B:$38; RGB:$39C7),

  (R:$44; G:$44; B:$44; RGB:$4228),

  (R:$50; G:$50; B:$50; RGB:$528A),

  (R:$61; G:$61; B:$61; RGB:$630C),

  (R:$71; G:$71; B:$71; RGB:$738E),

  (R:$81; G:$81; B:$81; RGB:$8410),

  (R:$91; G:$91; B:$91; RGB:$9492),

  (R:$A1; G:$A1; B:$A1; RGB:$A514),

  (R:$B6; G:$B6; B:$B6; RGB:$B5B6),

  (R:$CA; G:$CA; B:$CA; RGB:$CE59),

  (R:$E2; G:$E2; B:$E2; RGB:$E71C),

  (R:$FF; G:$FF; B:$FF; RGB:$),

  (R:$00; G:$00; B:$FF; RGB:$001F),

  (R:$40; G:$00; B:$FF; RGB:$401F),

  (R:$7D; G:$00; B:$FF; RGB:$781F),

  (R:$BE; G:$00; B:$FF; RGB:$B81F),

  (R:$FF; G:$00; B:$FF; RGB:$F81F),

  (R:$FF; G:$00; B:$BE; RGB:$F817),

  (R:$FF; G:$00; B:$7D; RGB:$F80F),

  (R:$FF; G:$00; B:$40; RGB:$F808),

  (R:$FF; G:$00; B:$00; RGB:$F800),

  (R:$FF; G:$40; B:$00; RGB:$FA00),

  (R:$FF; G:$7D; B:$00; RGB:$FBE0),

  (R:$FF; G:$BE; B:$00; RGB:$FDE0),

  (R:$FF; G:$FF; B:$00; RGB:$FFE0),

  (R:$BE; G:$FF; B:$00; RGB:$BFE0),

  (R:$7D; G:$FF; B:$00; RGB:$7FE0),

  (R:$40; G:$FF; B:$00; RGB:$47E0),

  (R:$00; G:$FF; B:$00; RGB:$07E0),

  (R:$00; G:$FF; B:$40; RGB:$07E8),

  (R:$00; G:$FF; B:$7D; RGB:$07EF),

  (R:$00; G:$FF; B:$BE; RGB:$07F7),

  (R:$00; G:$FF; B:$FF; RGB:$07FF),

  (R:$00; G:$BE; B:$FF; RGB:$05FF),

  (R:$00; G:$7D; B:$FF; RGB:$03FF),

  (R:$00; G:$40; B:$FF; RGB:$021F),

  (R:$7D; G:$7D; B:$FF; RGB:$7BFF),

  (R:$9D; G:$7D; B:$FF; RGB:$9BFF),

  (R:$BE; G:$7D; B:$FF; RGB:$BBFF),

  (R:$DE; G:$7D; B:$FF; RGB:$DBFF),

  (R:$FF; G:$7D; B:$FF; RGB:$FBFF),

  (R:$FF; G:$7D; B:$DE; RGB:$FBFB),

  (R:$FF; G:$7D; B:$BE; RGB:$FBF7),

  (R:$FF; G:$7D; B:$9D; RGB:$FBF3),

  (R:$FF; G:$7D; B:$7D; RGB:$FBEF),

  (R:$FF; G:$9D; B:$7D; RGB:$FCEF),

  (R:$FF; G:$BE; B:$7D; RGB:$FDEF),

  (R:$FF; G:$DE; B:$7D; RGB:$FEEF),

  (R:$FF; G:$FF; B:$7D; RGB:$FFEF),

  (R:$DE; G:$FF; B:$7D; RGB:$DFEF),

  (R:$BE; G:$FF; B:$7D; RGB:$BFEF),

  (R:$9D; G:$FF; B:$7D; RGB:$9FEF),

  (R:$7D; G:$FF; B:$7D; RGB:$7FEF),

  (R:$7D; G:$FF; B:$9D; RGB:$7FF3),

  (R:$7D; G:$FF; B:$BE; RGB:$7FF7),

  (R:$7D; G:$FF; B:$DE; RGB:$7FFB),

  (R:$7D; G:$FF; B:$FF; RGB:$7FFF),

  (R:$7D; G:$DE; B:$FF; RGB:$7EFF),

  (R:$7D; G:$BE; B:$FF; RGB:$7DFF),

  (R:$7D; G:$9D; B:$FF; RGB:$7CFF),

  (R:$B6; G:$B6; B:$FF; RGB:$B5BF),

  (R:$C6; G:$B6; B:$FF; RGB:$C5BF),

  (R:$DA; G:$B6; B:$FF; RGB:$DDBF),

  (R:$EA; G:$B6; B:$FF; RGB:$EDBF),

  (R:$FF; G:$B6; B:$FF; RGB:$FDBF),

  (R:$FF; G:$B6; B:$EA; RGB:$FDBD),

  (R:$FF; G:$B6; B:$DA; RGB:$FDBB),

  (R:$FF; G:$B6; B:$C6; RGB:$FDB8),

  (R:$FF; G:$B6; B:$B6; RGB:$FDB6),

  (R:$FF; G:$C6; B:$B6; RGB:$FE36),

  (R:$FF; G:$DA; B:$B6; RGB:$FED6),

  (R:$FF; G:$EA; B:$B6; RGB:$FF56),

  (R:$FF; G:$FF; B:$B6; RGB:$FFF6),

  (R:$EA; G:$FF; B:$B6; RGB:$EFF6),

  (R:$DA; G:$FF; B:$B6; RGB:$DFF6),

  (R:$C6; G:$FF; B:$B6; RGB:$C7F6),

  (R:$B6; G:$FF; B:$B6; RGB:$B7F6),

  (R:$B6; G:$FF; B:$C6; RGB:$B7F8),

  (R:$B6; G:$FF; B:$DA; RGB:$B7FB),

  (R:$B6; G:$FF; B:$EA; RGB:$B7FD),

  (R:$B6; G:$FF; B:$FF; RGB:$B7FF),

  (R:$B6; G:$EA; B:$FF; RGB:$B75F),

  (R:$B6; G:$DA; B:$FF; RGB:$B6DF),

  (R:$B6; G:$C6; B:$FF; RGB:$B63F),

  (R:$00; G:$00; B:$71; RGB:$000E),

  (R:$1C; G:$00; B:$71; RGB:$180E),

  (R:$38; G:$00; B:$71; RGB:$380E),

  (R:$55; G:$00; B:$71; RGB:$500E),

  (R:$71; G:$00; B:$71; RGB:$700E),

  (R:$71; G:$00; B:$55; RGB:$700A),

  (R:$71; G:$00; B:$38; RGB:$7007),

  (R:$71; G:$00; B:$1C; RGB:$7003),

  (R:$71; G:$00; B:$00; RGB:$7000),

  (R:$71; G:$1C; B:$00; 

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-29 Thread James Richters
I defined a static array to convert the mode 13h VGA palette to separate red, 
green and blue to send to aggpas as well as the packed RGB565 format needed to 
send to ptcgraph 16bit colors.

James


Type 
   VGARGBRec= Record
  R,G,B:Byte;
  RGB:Word;
   end;

Const
   VGA256: Array[0..255] of VGARGBRec = (
  (R:$00; G:$00; B:$00; RGB:$),
  (R:$00; G:$00; B:$AA; RGB:$0015),
  (R:$00; G:$AA; B:$00; RGB:$0540),
  (R:$00; G:$AA; B:$AA; RGB:$0555),
  (R:$AA; G:$00; B:$00; RGB:$A800),
  (R:$AA; G:$00; B:$AA; RGB:$A815),
  (R:$AA; G:$55; B:$00; RGB:$AAA0),
  (R:$AA; G:$AA; B:$AA; RGB:$AD55),
  (R:$55; G:$55; B:$55; RGB:$52AA),
  (R:$55; G:$55; B:$FF; RGB:$52BF),
  (R:$55; G:$FF; B:$55; RGB:$57EA),
  (R:$55; G:$FF; B:$FF; RGB:$57FF),
  (R:$FF; G:$55; B:$55; RGB:$FAAA),
  (R:$FF; G:$55; B:$FF; RGB:$FABF),
  (R:$FF; G:$FF; B:$55; RGB:$FFEA),
  (R:$FF; G:$FF; B:$FF; RGB:$),
  (R:$00; G:$00; B:$00; RGB:$),
  (R:$14; G:$14; B:$14; RGB:$10A2),
  (R:$20; G:$20; B:$20; RGB:$2104),
  (R:$2C; G:$2C; B:$2C; RGB:$2965),
  (R:$38; G:$38; B:$38; RGB:$39C7),
  (R:$44; G:$44; B:$44; RGB:$4228),
  (R:$50; G:$50; B:$50; RGB:$528A),
  (R:$61; G:$61; B:$61; RGB:$630C),
  (R:$71; G:$71; B:$71; RGB:$738E),
  (R:$81; G:$81; B:$81; RGB:$8410),
  (R:$91; G:$91; B:$91; RGB:$9492),
  (R:$A1; G:$A1; B:$A1; RGB:$A514),
  (R:$B6; G:$B6; B:$B6; RGB:$B5B6),
  (R:$CA; G:$CA; B:$CA; RGB:$CE59),
  (R:$E2; G:$E2; B:$E2; RGB:$E71C),
  (R:$FF; G:$FF; B:$FF; RGB:$),
  (R:$00; G:$00; B:$FF; RGB:$001F),
  (R:$40; G:$00; B:$FF; RGB:$401F),
  (R:$7D; G:$00; B:$FF; RGB:$781F),
  (R:$BE; G:$00; B:$FF; RGB:$B81F),
  (R:$FF; G:$00; B:$FF; RGB:$F81F),
  (R:$FF; G:$00; B:$BE; RGB:$F817),
  (R:$FF; G:$00; B:$7D; RGB:$F80F),
  (R:$FF; G:$00; B:$40; RGB:$F808),
  (R:$FF; G:$00; B:$00; RGB:$F800),
  (R:$FF; G:$40; B:$00; RGB:$FA00),
  (R:$FF; G:$7D; B:$00; RGB:$FBE0),
  (R:$FF; G:$BE; B:$00; RGB:$FDE0),
  (R:$FF; G:$FF; B:$00; RGB:$FFE0),
  (R:$BE; G:$FF; B:$00; RGB:$BFE0),
  (R:$7D; G:$FF; B:$00; RGB:$7FE0),
  (R:$40; G:$FF; B:$00; RGB:$47E0),
  (R:$00; G:$FF; B:$00; RGB:$07E0),
  (R:$00; G:$FF; B:$40; RGB:$07E8),
  (R:$00; G:$FF; B:$7D; RGB:$07EF),
  (R:$00; G:$FF; B:$BE; RGB:$07F7),
  (R:$00; G:$FF; B:$FF; RGB:$07FF),
  (R:$00; G:$BE; B:$FF; RGB:$05FF),
  (R:$00; G:$7D; B:$FF; RGB:$03FF),
  (R:$00; G:$40; B:$FF; RGB:$021F),
  (R:$7D; G:$7D; B:$FF; RGB:$7BFF),
  (R:$9D; G:$7D; B:$FF; RGB:$9BFF),
  (R:$BE; G:$7D; B:$FF; RGB:$BBFF),
  (R:$DE; G:$7D; B:$FF; RGB:$DBFF),
  (R:$FF; G:$7D; B:$FF; RGB:$FBFF),
  (R:$FF; G:$7D; B:$DE; RGB:$FBFB),
  (R:$FF; G:$7D; B:$BE; RGB:$FBF7),
  (R:$FF; G:$7D; B:$9D; RGB:$FBF3),
  (R:$FF; G:$7D; B:$7D; RGB:$FBEF),
  (R:$FF; G:$9D; B:$7D; RGB:$FCEF),
  (R:$FF; G:$BE; B:$7D; RGB:$FDEF),
  (R:$FF; G:$DE; B:$7D; RGB:$FEEF),
  (R:$FF; G:$FF; B:$7D; RGB:$FFEF),
  (R:$DE; G:$FF; B:$7D; RGB:$DFEF),
  (R:$BE; G:$FF; B:$7D; RGB:$BFEF),
  (R:$9D; G:$FF; B:$7D; RGB:$9FEF),
  (R:$7D; G:$FF; B:$7D; RGB:$7FEF),
  (R:$7D; G:$FF; B:$9D; RGB:$7FF3),
  (R:$7D; G:$FF; B:$BE; RGB:$7FF7),
  (R:$7D; G:$FF; B:$DE; RGB:$7FFB),
  (R:$7D; G:$FF; B:$FF; RGB:$7FFF),
  (R:$7D; G:$DE; B:$FF; RGB:$7EFF),
  (R:$7D; G:$BE; B:$FF; RGB:$7DFF),
  (R:$7D; G:$9D; B:$FF; RGB:$7CFF),
  (R:$B6; G:$B6; B:$FF; RGB:$B5BF),
  (R:$C6; G:$B6; B:$FF; RGB:$C5BF),
  (R:$DA; G:$B6; B:$FF; RGB:$DDBF),
  (R:$EA; G:$B6; B:$FF; RGB:$EDBF),
  (R:$FF; G:$B6; B:$FF; RGB:$FDBF),
  (R:$FF; G:$B6; B:$EA; RGB:$FDBD),
  (R:$FF; G:$B6; B:$DA; RGB:$FDBB),
  (R:$FF; G:$B6; B:$C6; RGB:$FDB8),
  (R:$FF; G:$B6; B:$B6; RGB:$FDB6),
  (R:$FF; G:$C6; B:$B6; RGB:$FE36),
  (R:$FF; G:$DA; B:$B6; RGB:$FED6),
  (R:$FF; G:$EA; B:$B6; RGB:$FF56),
  (R:$FF; G:$FF; B:$B6; RGB:$FFF6),
  (R:$EA; G:$FF; B:$B6; RGB:$EFF6),
  (R:$DA; G:$FF; B:$B6; RGB:$DFF6),
  (R:$C6; G:$FF; B:$B6; RGB:$C7F6),
  (R:$B6; G:$FF; B:$B6; RGB:$B7F6),
  (R:$B6; G:$FF; B:$C6; RGB:$B7F8),
  (R:$B6; G:$FF; B:$DA; RGB:$B7FB),
  (R:$B6; G:$FF; B:$EA; RGB:$B7FD),
  (R:$B6; G:$FF; B:$FF; RGB:$B7FF),
  (R:$B6; G:$EA; B:$FF; RGB:$B75F),
  (R:$B6; G:$DA; B:$FF; RGB:$B6DF),
  (R:$B6; G:$C6; B:$FF; RGB:$B63F),
  (R:$00; G:$00; B:$71; RGB:$000E),
  (R:$1C; G:$00; B:$71; RGB:$180E),
  (R:$38; G:$00; B:$71; RGB:$380E),
  (R:$55; G:$00; B:$71; RGB:$500E),
  (R:$71; G:$00; B:$71; RGB:$700E),
  (R:$71; G:$00; B:$55; RGB:$700A),
  (R:$71; G:$00; B:$38; RGB:$7007),
  (R:$71; G:$00; B:$1C; RGB:$7003),
  (R:$71; G:$00; B:$00; RGB:$7000),
  (R:$71; G:$1C; B:$00; RGB:$70E0),
  (R:$71; G:$38; B:$00; RGB:$71C0),
  (R:$71; G:$55; B:$00; RGB:$72A0),
  (R:$71; G:$71; B:$00; RGB:$7380),
  

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-29 Thread James Richters
>Your palette looks like standard Int Mode 13h VGA palette (yes, I'm older). 
>This are the RGB values (I'm quite sure):

Thank you, I appreciate the help identifying the format I have and the 
conversion to RGB.  I was able to also find methods to convert RGB to RGB565 
and back by looking in  the aggpas pf_rgb565.inc file.

{ make_pix_565 }
function make_pix_565(r ,g ,b : unsigned ) : int16u;
begin
 result:=
  ((r and $F8 ) shl 8 ) or
  ((g and $FC ) shl 3 ) or
   (b shr 3 );

end;

{ make_color_565 }
procedure make_color_565(var color : aggclr; p : int16u_ptr );
begin
 color.ConstrInt(
  (p^ shr 8 ) and $F8 ,
  (p^ shr 3 ) and $FC ,
  (p^ shl 3 ) and $F8 );

end;   

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-28 Thread José Mejuto

El 28/06/2017 a las 23:50, James Richters escribió:

The two color schemes are nothing alike.  16bit is using this RGB565 format, 
but 8bit colors (at least the version I was using) the colors have no real 
relation to their bits (see thishttps://pasteboard.co/2K38l6Gk1.png)  I can't 
figure out any pattern to this at all and while some colors I can figure out, 
others would be quite difficult.


Hello,

Your palette looks like standard Int Mode 13h VGA palette (yes, I'm 
older). This are the RGB values (I'm quite sure):


palette[  0] = rgb(  0,  0,  0)
palette[  1] = rgb(  0,  0,170)
palette[  2] = rgb(  0,170,  0)
palette[  3] = rgb(  0,170,170)
palette[  4] = rgb(170,  0,  0)
palette[  5] = rgb(170,  0,170)
palette[  6] = rgb(170, 85,  0)
palette[  7] = rgb(170,170,170)
palette[  8] = rgb( 85, 85, 85)
palette[  9] = rgb( 85, 85,255)
palette[ 10] = rgb( 85,255, 85)
palette[ 11] = rgb( 85,255,255)
palette[ 12] = rgb(255, 85, 85)
palette[ 13] = rgb(255, 85,255)
palette[ 14] = rgb(255,255, 85)
palette[ 15] = rgb(255,255,255)
palette[ 16] = rgb(  0,  0,  0)
palette[ 17] = rgb( 20, 20, 20)
palette[ 18] = rgb( 32, 32, 32)
palette[ 19] = rgb( 44, 44, 44)
palette[ 20] = rgb( 56, 56, 56)
palette[ 21] = rgb( 68, 68, 68)
palette[ 22] = rgb( 80, 80, 80)
palette[ 23] = rgb( 97, 97, 97)
palette[ 24] = rgb(113,113,113)
palette[ 25] = rgb(129,129,129)
palette[ 26] = rgb(145,145,145)
palette[ 27] = rgb(161,161,161)
palette[ 28] = rgb(182,182,182)
palette[ 29] = rgb(202,202,202)
palette[ 30] = rgb(226,226,226)
palette[ 31] = rgb(255,255,255)
palette[ 32] = rgb(  0,  0,255)
palette[ 33] = rgb( 64,  0,255)
palette[ 34] = rgb(125,  0,255)
palette[ 35] = rgb(190,  0,255)
palette[ 36] = rgb(255,  0,255)
palette[ 37] = rgb(255,  0,190)
palette[ 38] = rgb(255,  0,125)
palette[ 39] = rgb(255,  0, 64)
palette[ 40] = rgb(255,  0,  0)
palette[ 41] = rgb(255, 64,  0)
palette[ 42] = rgb(255,125,  0)
palette[ 43] = rgb(255,190,  0)
palette[ 44] = rgb(255,255,  0)
palette[ 45] = rgb(190,255,  0)
palette[ 46] = rgb(125,255,  0)
palette[ 47] = rgb( 64,255,  0)
palette[ 48] = rgb(  0,255,  0)
palette[ 49] = rgb(  0,255, 64)
palette[ 50] = rgb(  0,255,125)
palette[ 51] = rgb(  0,255,190)
palette[ 52] = rgb(  0,255,255)
palette[ 53] = rgb(  0,190,255)
palette[ 54] = rgb(  0,125,255)
palette[ 55] = rgb(  0, 64,255)
palette[ 56] = rgb(125,125,255)
palette[ 57] = rgb(157,125,255)
palette[ 58] = rgb(190,125,255)
palette[ 59] = rgb(222,125,255)
palette[ 60] = rgb(255,125,255)
palette[ 61] = rgb(255,125,222)
palette[ 62] = rgb(255,125,190)
palette[ 63] = rgb(255,125,157)
palette[ 64] = rgb(255,125,125)
palette[ 65] = rgb(255,157,125)
palette[ 66] = rgb(255,190,125)
palette[ 67] = rgb(255,222,125)
palette[ 68] = rgb(255,255,125)
palette[ 69] = rgb(222,255,125)
palette[ 70] = rgb(190,255,125)
palette[ 71] = rgb(157,255,125)
palette[ 72] = rgb(125,255,125)
palette[ 73] = rgb(125,255,157)
palette[ 74] = rgb(125,255,190)
palette[ 75] = rgb(125,255,222)
palette[ 76] = rgb(125,255,255)
palette[ 77] = rgb(125,222,255)
palette[ 78] = rgb(125,190,255)
palette[ 79] = rgb(125,157,255)
palette[ 80] = rgb(182,182,255)
palette[ 81] = rgb(198,182,255)
palette[ 82] = rgb(218,182,255)
palette[ 83] = rgb(234,182,255)
palette[ 84] = rgb(255,182,255)
palette[ 85] = rgb(255,182,234)
palette[ 86] = rgb(255,182,218)
palette[ 87] = rgb(255,182,198)
palette[ 88] = rgb(255,182,182)
palette[ 89] = rgb(255,198,182)
palette[ 90] = rgb(255,218,182)
palette[ 91] = rgb(255,234,182)
palette[ 92] = rgb(255,255,182)
palette[ 93] = rgb(234,255,182)
palette[ 94] = rgb(218,255,182)
palette[ 95] = rgb(198,255,182)
palette[ 96] = rgb(182,255,182)
palette[ 97] = rgb(182,255,198)
palette[ 98] = rgb(182,255,218)
palette[ 99] = rgb(182,255,234)
palette[100] = rgb(182,255,255)
palette[101] = rgb(182,234,255)
palette[102] = rgb(182,218,255)
palette[103] = rgb(182,198,255)
palette[104] = rgb(  0,  0,113)
palette[105] = rgb( 28,  0,113)
palette[106] = rgb( 56,  0,113)
palette[107] = rgb( 85,  0,113)
palette[108] = rgb(113,  0,113)
palette[109] = rgb(113,  0, 85)
palette[110] = rgb(113,  0, 56)
palette[111] = rgb(113,  0, 28)
palette[112] = rgb(113,  0,  0)
palette[113] = rgb(113, 28,  0)
palette[114] = rgb(113, 56,  0)
palette[115] = rgb(113, 85,  0)
palette[116] = rgb(113,113,  0)
palette[117] = rgb( 85,113,  0)
palette[118] = rgb( 56,113,  0)
palette[119] = rgb( 28,113,  0)
palette[120] = rgb(  0,113,  0)
palette[121] = rgb(  0,113, 28)
palette[122] = rgb(  0,113, 56)
palette[123] = rgb(  0,113, 85)
palette[124] = rgb(  0,113,113)
palette[125] = rgb(  0, 85,113)
palette[126] = rgb(  0, 56,113)
palette[127] = rgb(  0, 28,113)
palette[128] = rgb( 56, 56,113)
palette[129] = rgb( 68, 56,113)
palette[130] = rgb( 85, 56,113)
palette[131] = rgb( 97, 56,113)
palette[132] = rgb(113, 56,113)
palette[133] = rgb(113, 56, 97)
palette[134] = rgb(113, 56, 85)
palette[135] = rgb(113, 56, 68)
palette[136] = rgb(113, 56, 56)
palette[137] = rgb(113, 68, 56)
palette[138] = rgb(113, 85, 56)
palette[139] = 

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-28 Thread James Richters
I've figured out a way to get my animations to work fast and still have the 
quality of aggpas.  The problem I have is that even though I've managed to 
accelerate putimage() and it's pretty fast, it's still not fast enough and my 
animations in my program happen too slow, especially on slow computers.  I can 
build the screen fast with aggpas, and I can do putimage() pretty fast, but for 
some reason making a change with aggpas then putimage, then change aggpas then 
putimage... is slower.  So I came up with a solution.  I do the animations with 
ptcgraph commands at the same time I build the screen with aggpas, then when 
the animation is finished, I do my putimage() and replace the screen with the 
aggpas rendered version.  It works out that during the animation, the screen is 
changing distractingly fast that you really don't notice the lower quality 
graphics produced by ptcgraph routines, and when it stops and now you have a 
chance to look a it, the screen has been replaced with the aggpas version so 
everything looks nice and smooth    With this method I actually had to put a 
delay in my animation cycle or it was too fast and I lost the animation effect 
I was looking for.   

Now I'm ready to start integrating everything I learned into my real 
application and I have a question.
My original application used only 8bit colors, but now I am upgrading it to 
16bit colors because it will give aggpas more to work with for it's 
anti-aliasing.   Is there some formula or maybe even some function in 
freepascal somewhere that converts 8bit colors to their 16bit equivalents?   
The two color schemes are nothing alike.  16bit is using this RGB565 format, 
but 8bit colors (at least the version I was using) the colors have no real 
relation to their bits (see this https://pasteboard.co/2K38l6Gk1.png)  I can't 
figure out any pattern to this at all and while some colors I can figure out, 
others would be quite difficult.  I'm wondering if maybe there is already some 
translation from these 8bit color designations into 16bit color designations so 
all I would have to do is a global search and replace of setcolor(x) to 
setcolor(8bit_to_16bit(x)); and then all my colors would be the same as they 
were.

I'm also wondering if there is already some function to either convert the 
16bit RGB565 colors into separate 8bit values of red, green, and blue suitable 
to plug into aggpas procedures like 
agg^.lineColor(red, green, blue, 255);  I could probably manage something for 
this because it's pretty well defined that I have 5bits red, 6 bits green, and 
5 bits blue, but still I'm not exactly clear how it would get from 5 or 6 bits 
up to 8 bits per color...  but if it's already available somewhere I might as 
well use what's done already.

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-26 Thread Stefan V. Pantazi


On 06/26/2017 10:21 AM, James Richters wrote:

Is there a way to re-scale a drawing with agg_2D?


I think so, scaling is one of the transformations that agg supports 
well. The way I would go about this would be to study how agg manages 
the parsing, storage and display of svg drawings, which are basically 
collections of drawing commands, just like yours. Compile, run and 
analyze the code of svg examples, in particular svg_test demo (the one 
with the lion head).


I found a scale feature in aggpas but it only seems to scale items drawn 
after the command is issued.


Scaling is done through matrix multiplication but you need to have all 
your drawing commands stored in a similar way agg does it for svg, so 
that they can be redrawn. This is a more flexible approach than 
reiterating over hardcoded drawing commands. The cost is the increased 
complexity.


I'm wondering if there is a way to send aggpas all my lines and arcs, 
then give it a scale and offset, display it that way, then a different 
scale and offset, then redisplay it that way,


I think doing this in a way similar to svg routines is one way to go and 
may have its limitations. While significantly more complicated, you also 
get as a byproduct the capability of saving your screen (think 
screenshots, etc.) in standard svg format that can be persisted beyond 
your application lifecycle.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-26 Thread James Richters
Is there a way to re-scale a drawing with agg_2D?  Basically I'm wanting to 
zoom in/out of a drawing made with lines and arcs and I'm wondering the most 
efficient way to do it.  I found a scale feature in aggpas but it only seems to 
scale items drawn after the command is issued.  I'm wondering if there is a way 
to send aggpas all my lines and arcs, then give it a scale and offset, display 
it that way, then a different scale and offset, then redisplay it that way, or 
do I just need to do this myself and just clear aggpas and re-send the lines 
and arcs at the new scale and offset to aggpas from scratch.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-23 Thread James Richters
> lineto is meant to be used multiple times, as part of a draw path. So, lineto 
> does not really draw, 
>it just adds a vertex to a vertex storage object. To draw a path, you need to 
>use the drawPath(option):

Thank you for the information!  I thought I was missing something.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-23 Thread Stefan V. Pantazi
When in doubt, have a look at the source code of the graphical 
primitives to determine the semantics of each one. Unlike line primitive 
which draws a path immediately, lineto is meant to be used multiple 
times, as part of a draw path. So, lineto does not really draw, it just 
adds a vertex to a vertex storage object. To draw a path, you need to 
use the drawPath(option):


  agg^.lineWidth(4);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
  agg^.lineColor(155, 0, 0, 255);
  agg^.line(60, 10, 60, 50);
  agg^.lineto(100,50);   //no line drawn here, just adds to 
vertex storage

  agg^.drawPath(StrokeOnly);   //draw path
  agg^.lineColor(0, 0, 155, 255);
  agg^.moveto(100, 10);
  agg^.lineto(100,50);   //no line drawn here, just adds to 
vertex storage

  agg^.drawPath(StrokeOnly);   //draw path
  agg^.lineColor(155, 0, 155, 255);
  agg^.line(120, 10, 120, 50);


On 06/23/2017 01:27 PM, James Richters wrote:

I'm trying to switch over a program to use aggpas but I'm not getting any 
results from moveto or lineto am I missing something?

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-23 Thread James Richters
I'm trying to switch over a program to use aggpas but I'm not getting any 
results from moveto or lineto am I missing something?

I made a little demo that illustrates what's happening

  agg^.lineWidth(4);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
  agg^.lineColor(155, 0, 0, 255);
  agg^.line(60, 10, 60, 50);
  agg^.lineto(100,50);   //no line drawn here
  agg^.lineColor(0, 0, 155, 255);
  agg^.moveto(100, 10);
  agg^.lineto(100,50);//no line drawn  here
  agg^.lineColor(155, 0, 155, 255);
  agg^.line(120, 10, 120, 50);

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-23 Thread Martin Schreiber
On Thursday 22 June 2017 18:47:40 James Richters wrote:
> I squeezed a little more out of putimage by doing as little math as
> possible with a couple of variables to store j*ptcwidth and i+j*ptcwidth  I
> got my 1000x test loop down to 1.013 seconds.  Here is what it looks like
> at the moment, any ideas on how to optimize it further?
>
"
var
  pixels:Pword;
  k: longint;
  i, j, y1, x1, deltaX, deltaX1, deltaY: smallint;
  JxW, I_JxW: Longword;
  sourcepo,destpo,endpo: pcard16;
[...]
XORPut:
  Begin
for j:=Y to Y1 do
  Begin
JxW:=j*PTCWidth;
inc(k,deltaX);

sourcepo:= @pt(bitmap)[k];
destpo:= @pixels[jxw+x];
endpo:= destpo+x1-x;
inc(k,x1-x+1);
while destpo <= endpo do begin
 destpo^:= destpo^ xor sourcepo^ and colormask;
 inc(sourcepo);
 inc(destpo);
end;
{
for i:=X to X1 do
  begin
I_JxW:=i+JxW;
pixels[I_JxW] := pixels[I_JxW] xor (pt(bitmap)[k] and 
ColorMask);
inc(k);
  end;
}
inc(k,deltaX1);
  End;
  End;
"
On 32 bit Linux with 1024x768 screen and bitmap:

FPC 3.0.3 -O-:
1001 runs
origin  2.2167833261452355E+000 ms per put
mse  2.0649356462366574E+000 ms per put

FPC 3.0.3 -O3:
1001 runs
origin  2.2787212782151454E+000 ms per put
mse  6.0739260367848180E-001 ms per put

MSElang with LLVM 3.8.0 backend no optimisation:
1001 runs
origin 1.97338 ms per put
mse 2.03776 ms per put

MSElang with LLVM 3.8.0 backend -O3:
1001 runs
origin 0.406554 ms per put
mse 0.454978 ms per put

The project is here:
https://gitlab.com/mseide-msegui/mselang/tree/master/mselang/benchmark/putimage

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-22 Thread Martin Schreiber
On Friday 23 June 2017 06:38:18 Martin Schreiber wrote:
> On Thursday 22 June 2017 18:47:40 James Richters wrote:
> > I squeezed a little more out of putimage by doing as little math as
> > possible with a couple of variables to store j*ptcwidth and i+j*ptcwidth 
> > I got my 1000x test loop down to 1.013 seconds.  Here is what it looks
> > like at the moment, any ideas on how to optimize it further?
>
> Please push your changes so we can work with the real code.
>
Sorry, I found it, it is in branch Avoid_ReChecking_Bitblt.

Martin


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-22 Thread Martin Schreiber
On Thursday 22 June 2017 18:47:40 James Richters wrote:
> I squeezed a little more out of putimage by doing as little math as
> possible with a couple of variables to store j*ptcwidth and i+j*ptcwidth  I
> got my 1000x test loop down to 1.013 seconds.  Here is what it looks like
> at the moment, any ideas on how to optimize it further?
>
Please push your changes so we can work with the real code.

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-22 Thread James Richters
I squeezed a little more out of putimage by doing as little math as possible 
with a couple of variables to store j*ptcwidth and i+j*ptcwidth  I got my 1000x 
test loop down to 1.013 seconds.  Here is what it looks like at the moment, any 
ideas on how to optimize it further?

 

https://github.com/Zaaphod/ptcpas/compare/master...Zaaphod_Custom#diff-fb31461e009ff29fda5c35c5115978b4

 

var

  pixels:Pword;

  k: longint;

  i, j, y1, x1, deltaX, deltaX1, deltaY: smallint;

  JxW, I_JxW: Longword;

..

XORPut: 

  Begin

for j:=Y to Y1 do

  Begin

JxW:=j*PTCWidth;

inc(k,deltaX);

for i:=X to X1 do

  begin

I_JxW:=i+JxW;

pixels[I_JxW] := pixels[I_JxW] xor pt(bitmap)[k];

inc(k);

  end;

inc(k,deltaX1);

  End;

  End;

..

 

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-22 Thread James Richters
>That sounds like a little bit of a special case - it'll work where you're 
>using putimage for a large area, that has very few pixels set. 

 

That is exactly what I have almost all the time.  I’m wanting to use putimage 
for the entire screen all the time, but very few pixels on the screen change at 
any given screen update.  I have already tried only using putimage for part of 
the screen, and that helps sometimes, but most of the time it doesn’t help 
enough, because I’ll be drawing a long diagonal line, or a big ellipse and to 
encase the entity in a rectangular shape ends using a good portion of the 
screen, and by the time I get done calculating how to make the only slightly 
smaller area, I might as well just did putimage on the entire screen.

 

>Perhaps just reimplementing the general algorithm in inline asm, by using SSE 
>(or MMX) vector instructions would be the fastest

 

That sounds completely over my head  

 

>but maybe it's not worth the pain

 

Maybe not…. I’m pretty sure I can handle processing the second array, but how 
and where to create it in aggpas, that I have no idea… yet… I have not actually 
tried to see how aggpas puts data in the buffer yet… It’s a huge package and 
I’m not sure what unit it’s even in.

 

>and the pascal implementation is fast enough for you.

 

It’s not quite fast enough yet…  

 

>Just experiment and see what works best :)

 

Sounds like fun    Maybe I’ll do a test and pre-build the second array myself, 
just to see if there is any real benefit to this whole idea and if there is 
then I’ll try to figure out how to do it with aggpas

 

>Btw, I looked at your code again and saw a quick and cheap optimization - just 
>move the case statement (case BitBlt of) outside the inner loop (for i:=X to 
>X1 do), so the value of BitBlt is not checked once every pixel, but once per 
>row.



Great Idea, I took it one step further, wanting it to be as fast as possible 
and only check BitBlt once for the entire nested loop.  I also made a combined 
procedure for both 8bpp and 16bpp.  This is about 7% faster. You can see it 
here:

https://github.com/Zaaphod/ptcpas/compare/Avoid_ReChecking_Bitblt#diff-fb31461e009ff29fda5c35c5115978b4

 

 

>Try rearranging that like this:

>..

>Code

>..

>Note that all array calculation and the case is removed from the inner most 
>loop, at the expense of duplicating the for loop. 

>The index is not used in the for loop and made 0 based to allow the tighest 
>FOR loop code generation.

 

I also tried this, but for some strange reason it’s slower.. clocking in at 
1.773s for my 1000x loop instead of 1.056s maybe I did something wrong.  Here 
is what I did:

https://github.com/Zaaphod/ptcpas/compare/Restructure_PutImage_Loop#diff-fb31461e009ff29fda5c35c5115978b4

maybe the two  inc(pdest); inc(psrc); inside the inner loop are slower than the 
inc(k)?

 

 

James

 

 





___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-22 Thread Marco van de Voort
In our previous episode, James Richters said:
> >putimage can be accelerated, although it would still have to do a memory 
> >copy.
> 
> Like this?
> https://github.com/Zaaphod/ptcpas/compare/Zaaphod_Custom?expand=1#diff-fb31461e009ff29fda5c35c5115978b4
> 
> This is amazingly faster.   I ran a test of just ptcgraph.putimage() in a
> loop, putting the same image over and over 1000 times and timing it.  The
> original ptcgraph.putimage() took 18.017 seconds.  After I applied this,
> the same loop took 1.056 seconds.  Quite an improvement!  It's still
> nowhere near as fast as just drawing stuff with ptcgraph directly, but for
> doing a memory copy of the entire screen, it's very fast

Try rearranging that like this:


var pdest,psrc: pword;
 

for j:=Y to Y1 do
   Begin
 inc(k,deltaX);
 pdest:=@pixels[X+j*PTCWidth];
 psrc:=@pt(bitmap)[k];
 case BitBlt of
   XORPut:   for i:=0 to X1-X do
   begin
 pdest^:=pdest^ xor psrc^;
 inc(pdest); inc(psrc);
   end;
  // etc other cases similarly
end;
 inc(k,x1-x+1); // we must make up for as many K updates as the for loop.
 inc(k,deltaX1);
end;

Note that all array calculation and the case is removed from the inner most
loop, at the expense of duplicating the for loop. The index is not used in
the for loop and made 0 based to allow the tighest FOR loop code generation.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread Nikolay Nikolov



On 06/22/2017 02:42 AM, Nikolay Nikolov wrote:



On 06/22/2017 01:21 AM, James Richters wrote:
putimage can be accelerated, although it would still have to do a 
memory copy.

Like this?
https://github.com/Zaaphod/ptcpas/compare/Zaaphod_Custom?expand=1#diff-fb31461e009ff29fda5c35c5115978b4 



This is amazingly faster.   I ran a test of just ptcgraph.putimage() 
in a loop, putting the same image over and over 1000 times and timing 
it.  The original ptcgraph.putimage() took 18.017 seconds.  After I 
applied this, the same loop took 1.056 seconds.  Quite an 
improvement!It's still nowhere near as fast as just drawing stuff 
with ptcgraph directly, but for doing a memory copy of the entire 
screen, it's very fast

Yes, that's a good start. That was exactly what I meant :)


I have an idea on how I could speed it up even further
If I set up a second array with 1 bit per pixel, then (somehow) 
aggpas could set bits in this array to 1 whenever it changed a 
corresponding bit.  Now by analyzing the 'pixel changed' array one 
word at a time, (or maybe longword or qword at a time)  I could just 
skip over all the words that =0 and when I come across a word that <> 
0   I could do a binary search of that word to only change the pixels 
that need to be changed.  If very little on the screen has changed, 
this would be quite a bit faster because the pixel changed array 
would be 1/16 the size of the full buffer.


The only way this would be of any benefit though is if aggpas set the 
bits in the 'pixel changed' array while it was changing the pixels of 
the buffer, because at that time it already has the array position 
and the fact that something changed available.  If I had to analyze 
the buffer separately and create the 'pixels changed' array, it would 
take too long.
That sounds like a little bit of a special case - it'll work where 
you're using putimage for a large area, that has very few pixels set. 
Perhaps just reimplementing the general algorithm in inline asm, by 
using SSE (or MMX) vector instructions would be the fastest, but maybe 
it's not worth the pain and the pascal implementation is fast enough 
for you. Just experiment and see what works best :)
Btw, I looked at your code again and saw a quick and cheap optimization 
- just move the case statement (case BitBlt of) outside the inner loop 
(for i:=X to X1 do), so the value of BitBlt is not checked once every 
pixel, but once per row.


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread Nikolay Nikolov



On 06/22/2017 01:21 AM, James Richters wrote:

putimage can be accelerated, although it would still have to do a memory copy.

Like this?
https://github.com/Zaaphod/ptcpas/compare/Zaaphod_Custom?expand=1#diff-fb31461e009ff29fda5c35c5115978b4

This is amazingly faster.   I ran a test of just ptcgraph.putimage() in a loop, 
putting the same image over and over 1000 times and timing it.  The original 
ptcgraph.putimage() took 18.017 seconds.  After I applied this, the same loop 
took 1.056 seconds.  Quite an improvement!It's still nowhere near as fast 
as just drawing stuff with ptcgraph directly, but for doing a memory copy of 
the entire screen, it's very fast

Yes, that's a good start. That was exactly what I meant :)


I have an idea on how I could speed it up even further
If I set up a second array with 1 bit per pixel, then (somehow) aggpas could set bits 
in this array to 1 whenever it changed a corresponding bit.  Now by analyzing the 
'pixel changed' array one word at a time, (or maybe longword or qword at a time)  I 
could just skip over all the words that =0 and when I come across a word that 
<> 0   I could do a binary search of that word to only change the pixels that 
need to be changed.  If very little on the screen has changed, this would be quite a 
bit faster because the pixel changed array would be 1/16 the size of the full buffer.

The only way this would be of any benefit though is if aggpas set the bits in 
the 'pixel changed' array while it was changing the pixels of the buffer, 
because at that time it already has the array position and the fact that 
something changed available.  If I had to analyze the buffer separately and 
create the 'pixels changed' array, it would take too long.
That sounds like a little bit of a special case - it'll work where 
you're using putimage for a large area, that has very few pixels set. 
Perhaps just reimplementing the general algorithm in inline asm, by 
using SSE (or MMX) vector instructions would be the fastest, but maybe 
it's not worth the pain and the pascal implementation is fast enough for 
you. Just experiment and see what works best :)


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread James Richters
>putimage can be accelerated, although it would still have to do a memory copy.

Like this?
https://github.com/Zaaphod/ptcpas/compare/Zaaphod_Custom?expand=1#diff-fb31461e009ff29fda5c35c5115978b4

This is amazingly faster.   I ran a test of just ptcgraph.putimage() in a loop, 
putting the same image over and over 1000 times and timing it.  The original 
ptcgraph.putimage() took 18.017 seconds.  After I applied this, the same loop 
took 1.056 seconds.  Quite an improvement!It's still nowhere near as fast 
as just drawing stuff with ptcgraph directly, but for doing a memory copy of 
the entire screen, it's very fast

I have an idea on how I could speed it up even further 
If I set up a second array with 1 bit per pixel, then (somehow) aggpas could 
set bits in this array to 1 whenever it changed a corresponding bit.  Now by 
analyzing the 'pixel changed' array one word at a time, (or maybe longword or 
qword at a time)  I could just skip over all the words that =0 and when I come 
across a word that <> 0   I could do a binary search of that word to only 
change the pixels that need to be changed.  If very little on the screen has 
changed, this would be quite a bit faster because the pixel changed array would 
be 1/16 the size of the full buffer. 

The only way this would be of any benefit though is if aggpas set the bits in 
the 'pixel changed' array while it was changing the pixels of the buffer, 
because at that time it already has the array position and the fact that 
something changed available.  If I had to analyze the buffer separately and 
create the 'pixels changed' array, it would take too long.


James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread Nikolay Nikolov



On 06/21/2017 10:27 PM, James Richters wrote:

I was trying to find putimage to see how it worked...  and I came across some 
notes about it in graph.inc as follows:
{ For significant speed improvements , is is recommended }
{ that these routines be hooked (otherwise the default,  }
{ slower routines will be used) :}
..
{   PutImage()   }
..

what does 'these routines be hooked'  mean?  Is that something I should be 
doing in my program or something that is already done internally with ptcgraph?
Something to be done in the ptcgraph sources, so that putimage becomes 
faster.


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread James Richters
I was trying to find putimage to see how it worked...  and I came across some 
notes about it in graph.inc as follows:
{ For significant speed improvements , is is recommended }  
{ that these routines be hooked (otherwise the default,  }
{ slower routines will be used) :}
..
{   PutImage()   }
..

what does 'these routines be hooked'  mean?  Is that something I should be 
doing in my program or something that is already done internally with ptcgraph?


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread Nikolay Nikolov



On 06/21/2017 08:05 PM, James Richters wrote:

Is there a more direct way of getting aggpas to send its output to ptcgraph?   
Currently I'm doing as in the demo programs and defining an array then using 
putimage() to transfer the array to ptcgraph... this is fairly slow, especially 
for fullscreen high resolution applications.   I'm trying to follow through 
some of the demos included with ptcpas and it seems they do something like:

{ lock surface pixels }
pixels := surface.lock;

Then using a pointer defined by pixels, the program makes changes to all the 
pixels, then

{ unlock surface }
surface.unlock;
and
{ copy surface to console }
  surface.copy(console, area, area);

send the changes to the screen.   I'm wondering if I can have aggpas work with 
the ptcgraph buffer directly, and maybe this would be more efficient than 
putimage()

Any ideas?
It's more complicated than that, because ptcgraph does all these 
operations in a separate thread. See the sources for ptcgraph and for 
the ptcwrapper unit. However, putimage can be accelerated, although it 
would still have to do a memory copy. This can be done, by implementing 
and adding a PutImage procedure in the TModeInfo record, which is filled 
in, during initialization. See the QueryAdapterInfo function in the 
ptcgraph.pp. It does a series of:


InitMode(graphmode);
with graphmode do
begin
  ...
end;

And inside the 'with' statement, various procedure variables are set. 
There, a PutImage routine can be added as well. Look at e.g. 
ptc_putpixelproc_16bpp to see how the surface is locked and how the 
actual drawing to the surface is done, inside ptcgraph.


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread James Richters
Is there a more direct way of getting aggpas to send its output to ptcgraph?   
Currently I'm doing as in the demo programs and defining an array then using 
putimage() to transfer the array to ptcgraph... this is fairly slow, especially 
for fullscreen high resolution applications.   I'm trying to follow through 
some of the demos included with ptcpas and it seems they do something like:

{ lock surface pixels }
pixels := surface.lock;

Then using a pointer defined by pixels, the program makes changes to all the 
pixels, then

{ unlock surface }
surface.unlock;
and
{ copy surface to console }
 surface.copy(console, area, area);

send the changes to the screen.   I'm wondering if I can have aggpas work with 
the ptcgraph buffer directly, and maybe this would be more efficient than 
putimage()

Any ideas?

James

  

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-21 Thread James Richters
>The 2 part directory names is because other Canvas renderers will and 
>can be added to fpGUI. 

Yes the directory structure makes more sense if there will be other 
rendering options and render/aggpas/ also makes more sense than 
render/software for the same reason.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-20 Thread Graeme Geldenhuys

On 2017-06-20 11:17, James Richters wrote:

That will be a great help.   Might I suggest mentioning the existence
and use of Agg2D in agg_2D and vice versa?  Something like:


Ah yes, I forgot about that. I'll add it now.



I also think you have made enough changes to it to warrant version
number changes.


After moving AggPas into the fpGUI repository, I don't consider it a 
separate "project" as such - even though it can still be used 
independent from fpGUI. So the original AggPas version numbering is of 
no concern to me any more, it will now follow the versions of fpGUI itself.


The unit header comment does mention that I forked it from the original 
2.4 RM3 AggPas, but that things diverged from there.




I'm also strongly considering renaming the "render/software/"
directory to "render/aggpas/". I'll mull this over for another day
or two.


I like the proposed directory name.  I wonder if it really needs 2
directories, why not just render-aggpas/ or aggpas-render/  ?


The 2 part directory names is because other Canvas renderers will and 
can be added to fpGUI. eg: Locally I already have a user contributed 
Cairo canvas renderer which lives in the "render/cairo/" directory, but 
has not been made public yet in the Github/SourceForge repositories. 
This is also why I think I should rename the "render/software/" 
directory to "render/aggpas/" - it makes things much clearer.


I'm also thinking of refactoring the X11 and GDI canvas rendering code, 
so they too live in the "render/*" directory hierarchy.


I also know of a user that is working on a OpenGL renderer for fpGUI.



Since there are going to be changes that require adjustments anyway,
I wonder if it would make sense to just make agg_2D always require
the pixel format in the constructor:

constructor Agg2D.Construct_PF(pixfmt:define_pixfmt);

It seems the original intention of aggpas was to have this
flexibility but somewhere along the way things like rgba ended up
getting hard coded into it.


A very good point. I'll make a note to commit those changes too.



Better off to just fix it then fix any programs as needed instead of
having an even bigger and more confusing mess that no one will
remember why it's like that in 5 years.


Exactly!



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-19 Thread Graeme Geldenhuys

On 2017-06-19 01:35, James Richters wrote:

The problem is not with rendering with rgb565,  the problem is something in the 
original that was patched with the setcolor function:

Line 122 of agg_color pas has:
constructor rgba8.Construct;
begin
 b{*}:=int8u(r_ );
 g:=int8u(g_ );
 r:=int8u(b_ );
 a:=int8u(a_ );

end;



WOW, well spotted - and how that went unnoticed for all these years is 
beyond me. Well done for bringing it to our attention.


That is a fundamental bug in AggPas, and something I'll be fixing 
immediately in fpGUI's repository. As for the affects on other code and 
programs. I'll do some testing to see what exact affect it has, and then 
add some notes in the CHANGELOG document describing code-breaking 
changes and recommended fixes.


I have always been in the mind that fundamental code and API's should be 
100% correct, and fixed promptly when a bug is found. Applications that 
are affected by such changes need to be updated - that's the bottom 
line. No point in continue maintaining buggy code and API's and 
guaranteed that things will just get worse in the future - if not 
immediately fixed.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-19 Thread Graeme Geldenhuys

On 2017-06-16 01:51, James Richters wrote:

Yeah, probably not the best naming convention.

>

Perhaps some comments at the top of both units explaining the
difference and also mentioning the other unit exits would save some
confusion



I have applied such a change. So far only to the Agg2D and agg_2D units, 
but I'll do the same to the rest of the units shortly.


I'm also strongly considering renaming the "render/software/" directory 
to "render/aggpas/". I'll mull this over for another day or two.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-18 Thread Stefan V. Pantazi

Good find and great sleuth work.

It is possible that the original reason for switching R and B channels 
was to make the agg color object more compatible with LCL which seems to 
prefer BGR, order, but who knows... One obvious problem seems to be


function AggToLCLColor(const c: TAggColor): TColor;

in Agg_LCL, that relies for conversion on RGBToColor in the Graphics unit.

function RGBToColor(R, G, B: Byte): TColor;
begin
  Result := (B shl 16) or (G shl 8) or R;
end;

Anyway, a quick search of the agg source code shows that the rgba8 
object is used only by a handful of units directly. Most agg units and 
demos use the more complicated aggclr object to represent color. I tried 
a few demos and seem unaffected by your fix. This explains why the bug 
was only clearly visible in your case, most of the other agg demos seem 
indiferent to the bug. On the other hand, besides agg_2D there are 
agg_fpimage, Agg2D (the one that integrates with LCL) that also use the 
rgba8 (through the TAggColor alias) and are clearly affected by the R 
and B swap when using canvas methods that involve the TAggColor object 
(e.g., AggClearAll, AggClearClipBox, etc). These would need to be 
updated as well. As an example, after your fix, the call 
canvas.AggClearAll(255,0,0) to TAggFPCanvas.AggClearAll(const r ,g ,b : 
byte; a : byte = 255 ) produces a blue background, which is clearly wrong.


On 06/18/2017 08:35 PM, James Richters wrote:



I finally partially figured out the red / blue color problem.
After single stepping through tons of the aggpas code for hours (it's quite 
complicated even to draw a line) with a sample program that just made a red 
line at the top, I discovered that it's actually doing everything exactly 
correct!   The problem is not with rendering with rgb565,  the problem is 
something in the original that was patched with the setcolor function:

Line 122 of agg_color pas has:
constructor rgba8.Construct;
begin
 b{*}:=int8u(r_ );
 g:=int8u(g_ );
 r:=int8u(b_ );
 a:=int8u(a_ );

end;

This switches red and blue... if I correct it to:
constructor rgba8.Construct;
begin
 b{*}:=int8u(b_ );
 g:=int8u(g_ );
 r:=int8u(r_ );
 a:=int8u(a_ );

end;

now my colors with rgb565 are correct. Since this is no logical reason to 
make b:=R_ and r:=B_ it seems more likely that with the rgba format somewhere 
along the way someone got lazy and just switched red and blue instead of fixing 
the pixelformat.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-18 Thread James Richters
>When you use the Windows GDI font engine, you don't have to specify the 
>location of the font - that is done for you in the font engine.
> Also you specify the font name like windows programs do, you don't specify 
> the font filename.

Thank you the information

I finally partially figured out the red / blue color problem.   
After single stepping through tons of the aggpas code for hours (it's quite 
complicated even to draw a line) with a sample program that just made a red 
line at the top, I discovered that it's actually doing everything exactly 
correct!   The problem is not with rendering with rgb565,  the problem is 
something in the original that was patched with the setcolor function:

Line 122 of agg_color pas has:
constructor rgba8.Construct;
begin
 b{*}:=int8u(r_ );
 g:=int8u(g_ );
 r:=int8u(b_ );
 a:=int8u(a_ );

end;

This switches red and blue... if I correct it to:
constructor rgba8.Construct;
begin
 b{*}:=int8u(b_ );
 g:=int8u(g_ );
 r:=int8u(r_ );
 a:=int8u(a_ );

end;

now my colors with rgb565 are correct. Since this is no logical reason to 
make b:=R_ and r:=B_ it seems more likely that with the rgba format somewhere 
along the way someone got lazy and just switched red and blue instead of fixing 
the pixelformat.

It became obvious that the original was the thing that was backwards, not the 
RGB565 patch because I kept stepping through things like:
constructor aggclr.Construct(rgba : rgba8 );
begin
 v:=(rgba.r * 77 + rgba.g * 150 + rgba.b * 29 ) shr 8;
 r:=rgba.r;
 g:=rgba.g;
 b:=rgba.b;
 a:=rgba.a;

end;
When I evaluated the variables 
R=0
G=0
B=255
A=255

But I defined a RED line, not a blue one.  

I used 
agg^.lineColor($FF, 0, 0, 255);

and according to:

procedure Agg2D.lineColor(r ,g ,b : unsigned; a : unsigned = 255 );
var
 clr : Color;

begin
 clr.Construct(r ,g ,b ,a );
 lineColor(clr );

end;

This should be red.

Every other function or procedure I came across with elements for red, green 
and blue kept coming up like this, so technically are incorrect.   Where the 
inconsistency come from to fix it properly.  For now I just made a compiler 
directive {$DEFINE AGG2D_USE_RGB565 } and use it to fix things in both agg_2D 
and agg_color.

I've committed these to a custom branch on my github fork of fpGUI at:
https://github.com/Zaaphod/fpGUI/tree/Zaaphod_Custom

I looked at the file history  in fpGUI and it looks like red and blue have been 
reversed like this since the initial import of aggpas into fpGUI,  when I look 
at the original example agg2dconsole.dpr, it has in it:
  c.red := getBufItemAsWord(2);
  c.green := getBufItemAsWord(1);
  c.blue := getBufItemAsWord(0);
  c.alpha := getBufItemAsWord(3);

but it should have been 

  c.red := getBufItemAsWord(0);
  c.green := getBufItemAsWord(1);
  c.blue := getBufItemAsWord(2);
  c.alpha := getBufItemAsWord(3);

and would have been if constructor rgba8.Construct; was correct... instead it 
was just re-reversed to compensate for the error in agg_color.pas.   My point 
here is that it may be too late to just correct it now, because then everyone 
who has programs that already 'fix' the problem will then all be wrong, so I'm 
not sure what the best way to fix this is.

James





-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Sunday, June 18, 2017 12:32 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-16 18:49, James Richters wrote:
> agg^.Font('C:\Windows\Fonts\ConsolaB.ttf' ,45 ) works fine, but as I  
> mentioned I can't be sure windows is installed in C:\Windows 

When you use the Windows GDI font engine, you don't have to specify the 
location of the font - that is done for you in the font engine. Also you 
specify the font name like windows programs do, you don't specify the font 
filename.

For example:

   agg^.LineWidth(1);
   agg^.Font('Consola' ,45, True); // Bold
   agg^.Text(300 ,100 ,'Consola font here.' );
   agg^.Font('Courier New' ,45, False, True );  // Italics
   agg^.Text(300 ,150 ,'Courier New font here.' );


Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-18 Thread Graeme Geldenhuys

On 2017-06-16 18:49, James Richters wrote:

agg^.Font('C:\Windows\Fonts\ConsolaB.ttf' ,45 )
works fine, but as I mentioned I can't be sure windows is installed in 
C:\Windows


When you use the Windows GDI font engine, you don't have to specify the 
location of the font - that is done for you in the font engine. Also you 
specify the font name like windows programs do, you don't specify the 
font filename.


For example:

  agg^.LineWidth(1);
  agg^.Font('Consola' ,45, True); // Bold
  agg^.Text(300 ,100 ,'Consola font here.' );
  agg^.Font('Courier New' ,45, False, True );  // Italics
  agg^.Text(300 ,150 ,'Courier New font here.' );


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-16 Thread James Richters
>You may be able to use CSIDL_FONTS or FOLDERID_Fonts as well.

 

Thank you for pointing me in the right direction.   I was able to get 
CSIDL_FONTS to work.  Getting the actual fonts folder is a better idea than 
assuming it’s in a \Fonts directory

 

I found an example on how to obtain the path from here:

http://wiki.lazarus.freepascal.org/Windows_Programming_Tips 

under “Getting special folders (My documents, Desktop, local application data, 
etc)”

 

Here is how I was able to get it to work.  I’m wondering if there is a better 
way to define my variables. I tried just making Font2Use a string but it didn’t 
compile;

 

Uses

  shlobj,

..

Var

  Font2Use,FontPath: Array[0..MaxPathLen] of Char; //Allocate memory

..

   SHGetSpecialFolderPath(0,FontPath,CSIDL_FONTS,false);

   writeln('Fonts: ' + FontPath);

   font2use:=FontPath+'\segoescb.ttf';

   Writeln(Font2use);

   agg^.Font(font2use ,45 );

..

 

 

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-16 Thread DaWorm
On Fri, Jun 16, 2017 at 1:49 PM, James Richters <
ja...@productionautomation.net> wrote:

>
> I would like to do something like:
> agg^.Font('%windir%\Fonts\ConsolaB.ttf' ,45 );
>
>
You should be able to use SHGetFolderPath() with CSIDL_WINDOWS.  Not sure
you can always count on Fonts being a subfolder of that, though.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762181(v=vs.85).aspx


You may be able to use CSIDL_FONTS or FOLDERID_Fonts as well.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx

Not sure if any are defined in FPC, but should be easy to create/import if
not.

Jeff.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-16 Thread James Richters
I've been able to use windows fonts with aggpas with the following code:
 
   agg^.Font('ConsolaB.ttf' ,45 );
   agg^.Text(300 ,100 ,'Text Here' );

and it works fine if I copy the font to the same folder as my program.  I'm 
wondering how I can just use standard windows fonts without copying them... but 
not assuming windows is installed in c:\windows

agg^.Font('C:\Windows\Fonts\ConsolaB.ttf' ,45 )
works fine, but as I mentioned I can't be sure windows is installed in 
C:\Windows

I would like to do something like: 
agg^.Font('%windir%\Fonts\ConsolaB.ttf' ,45 );

but of course that won't work because the %windir% variable only works in batch 
files.   

Is there some other way I can capture the install directory of windows, or the 
system so I can make this work properly?


Also, while I was tinkering with this,  I also wanted to see what differences 
there are between Freetype and Windows True Type fonts, and I noticed something 
odd.. 
If I compile with {$DEFINE AGG2D_USE_FREETYPE }  it works fine... but if I 
compile with it commented out,  it does work, and I get text on the screen, but 
the font is not the one I selected.  It seems to be a default font that I can't 
change. Does the font need to be defined differently if using Win32 TT font 
engine?I am using the current 'develop' branch of fpGUI version of aggpas 
now.  I have not tried it with the release version.

I'm also wondering if there is a way to specify the font by the name used by 
windows applications, or is that more complicated than it is really worth?

James



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread James Richters
>I use Git for just about any source code I work with. 
I've just recently started using GIT, and have been using it for my own 
applications.  My solution until now has been to duplicate any units that 
needed modification in with my source code so it would show up in my GIT 
repository.  But I like the idea of just maintain my own local copy and put a 
custom branch that I can keep maintained easier.. and who knows maybe I'll come 
up with something worth submitting to the project.

>We all love a mystery. ;-)
Especially once it's solved 

>Yeah, probably not the best naming convention.
Perhaps some comments at the top of both units explaining the difference and 
also mentioning the other unit exits would save some confusion

>The agg_2D.pas unit is a 100% non-GUI unit. It is meant for console or 
>web (eg: CGI) style applications. No GUI toolkit dependencies are required.

Sound like I was using the correct unit anyway for my console apps

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Stefan V. Pantazi
I was waiting for the right time to also offer my sincere thanks to all 
teams and individual contributors. I have been using fpc and Lazarus IDE 
for quite some years now and I am very pleased with the constant 
progress and improvement of these development tools. I have enjoyed 
reading and learned a lot on these mailing lists as well. My hope is 
that contributions continue for many years to come and that the 
community remains helpful as it has always been.


Stefan



Also when looking through the fpGUI as well as the Freepascal repositories,  
there are just thousands of commits.  looking at all those commits gives a real 
appreciation for the amount of work that has gone into the project.   So a huge 
thank you goes out to everyone who has worked so hard to make freepascal as 
awesome as it is, as well as the people who are such a tremendous help on this 
list.   Honestly if not for FreePascal, I would still be trying to put together 
Pentium 233 computers to run my old DOS applications on. (not fun, components 
are getting hard even to find on ebay now)   I just don't have time to do a 
massive re-write all at once, and FreePascal let me drop in my Turbo Pascal 
programs and pretty much just run them.

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 22:17, James Richters wrote:

I specifically looked for agg_2d.pas (which is the one I was using)
I found that it also was fixed, but only 11 months ago... after 1.4.1
was released.


Yes, that's my bad. The agg_2d.pas unit was lagging behind for a while, 
because I never really used it until about 12-18 months ago.




So mystery solved... but.


We all love a mystery. ;-)



It raises a new question... What is the difference between agg2D.pas
and agg_2D.pas and which one do I want to be using?


Yeah, probably not the best naming convention.

The agg_2D.pas unit is a 100% non-GUI unit. It is meant for console or 
web (eg: CGI) style applications. No GUI toolkit dependencies are required.


The "agg2D.pas" unit depends on fpGUI Toolkit, because it implements a 
fpGUI Canvas that uses AggPas for all it's 2D drawing routines. So it's 
a descendant of TfpgCanvasBase (a fpGUI class).




Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 15:06, James Richters wrote:

I don't like modifying units that are part of a package
because then I would need to remember how I modified them when a new
version is released or have to figure out what's going on all over
again.


I use Git for just about any source code I work with. I even let Git 
manage a SubVersion repository. I also often have my own "custom 
changes" in 3rd party code. With Git I simply create a "custom-mods" 
branch where I commit all my personal preferences. As the 3rd party code 
moves forward, I can move my whole "custom-mods" branch forward to by 
using the Git command "rebase". It's very little effort, and I have 
dragged some of my custom-mods branches forward since around 2010 (in 
various 3rd party code).




3) Make sure you always rebuild the unit depending on the program
you want to compile (Compile -> Build).

Is there a way to force this with the command line?


Yes.  The -B compiler command line parameter.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 13:34, Tomas Hajny wrote:

Not quite - the text-mode IDE doesn't invoke fpc.exe binary (it has the
compiler built-in) and it passes the options as defined in the respective
IDE dialogs.



Thanks Tomas for correcting me. I wasn't 100% sure about the behaviour 
of a compiled-in compiler.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread James Richters
>And if you look in the "develop" branch of fpGUI, there is an even later 
>AggPas version - last updated a month ago

I downloaded the fpGUI repository to have a look at it, and thought I would see 
if any of the things I was encountering with it were addressed yet.   Sure 
enough, I found

{$IFDEF AGG2D_USE_FREETYPE}
  {$UNDEF AGG2D_USE_WINFONTS}
{$ENDIF}

Already there,  actually formatted exactly the way I did to get it to compile.  
So I went back in the history of the file to see when that was added, and I 
found it 4 years ago!
This was really puzzling because I had to fix the version included with fpGUI 
1.4.1 which was from 2015.  

Well looking more closely, I discovered there are 2 units... agg2D.pas and 
agg_2D.pas.   well agg2D.pas is all the way at the bottom of all the agg_* 
units so I never knew it was there so when I specifically looked for 
agg_2d.pas (which is the one I was using)  I found that it also was fixed, but 
only 11 months ago... after 1.4.1 was released.  

So mystery solved... but.

It raises a new question... 
What is the difference between agg2D.pas and agg_2D.pas and which one do I want 
to be using?  

Also when looking through the fpGUI as well as the Freepascal repositories,  
there are just thousands of commits.  looking at all those commits gives a real 
appreciation for the amount of work that has gone into the project.   So a huge 
thank you goes out to everyone who has worked so hard to make freepascal as 
awesome as it is, as well as the people who are such a tremendous help on this 
list.   Honestly if not for FreePascal, I would still be trying to put together 
Pentium 233 computers to run my old DOS applications on. (not fun, components 
are getting hard even to find on ebay now)   I just don't have time to do a 
massive re-write all at once, and FreePascal let me drop in my Turbo Pascal 
programs and pretty much just run them.   

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Tomas Hajny
On Thu, June 15, 2017 16:06, James Richters wrote:
 .
 .
>> 3) Make sure you always rebuild the unit depending on the program you
>> want to compile (Compile -> Build).
>
> Is there a way to force this with the command line? (same as Compile >
> build from the IDE) ?

Yes, of course - it's the option '-B'.


 .
 .
> Oh, I see the issue here.   So If I were to write a unit that I wanted
> Programs to share, but have various options, I may be better off to define
> a variable in the unit and let the programs change the variable depending
> on what they want with the compiler directives, it's actually leaving
> out parts altogether, so you need to re-compile the unit if you want to
> change it... makes smaller files than always including things you don't
> want to use.
 .
 .

Yes, exactly (plus there are some more reasons, like that you want to
reduce unneeded dependencies which may not be fulfilled, etc.).

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread James Richters
Thanks everyone for explaining this,  and thanks for the various solutions.  I 
don't like modifying units that are part of a package because then I would need 
to remember how I modified them when a new version is released or have to 
figure out what's going on all over again.  

> 3) Make sure you always rebuild the unit depending on the program you want to 
> compile (Compile -> Build).

Is there a way to force this with the command line? (same as Compile > build 
from the IDE) ?

>Defines have impact only when compiling the particular source code. Having a 
>'global define' in a program could never have impact to a unit which might be 
>already compiled using different defines at the moment the particular program 
>is compiled. 

Oh, I see the issue here.   So If I were to write a unit that I wanted Programs 
to share, but have various options, I may be better off to define a variable in 
the unit and let the programs change the variable depending on what they 
want with the compiler directives, it's actually leaving out parts 
altogether, so you need to re-compile the unit if you want to change it... 
makes smaller files than always including things you don't want to use. 

>Yes, projects are 'a Lazarus thing'. However, you can achieve a similar effect 
>with local options and configuration files for the text-mode IDE (you just 
>need to use different directories for different 'projects').
Using directories sounds easy enough.  

>Alternatively you can pass @your.cfg to add a config.
That's good to know, and could be useful!   Since fp gets constantly re-saved 
when the IDE closes, it's possible that custom settings could be forgotten 
about and overwritten to not be there anymore.  Using a custom cfg with this 
method would allow the changes to be kept separate and be a more obvious 
reminder that they need to happen.  Can I add the custom config into the IDE 
someplace? 

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Mattias Gaertner
On Thu, 15 Jun 2017 07:57:14 -0400
"James Richters"  wrote:

> >The idea is that you have one project per program. You can compile them 
> >randomly without changing anything.  
> 
> I don't understand what you mean by 'one project per program' ?

Project is a Lazarus/msegui thing.

> I only have programs that I have sorted in sub directories.  I normally use 
> the Freepascal text IDE to compile them, and sometimes the command line.   I 
> might want to have ProgramA.pas have one define and ProgramB.pas have 
> another, both using the same unit, is there some method to do that?

Yes, via the fpc.cfg, via @your.cfg, via include files, via FPC IDE
config or by tools like Lazarus, msegui, make, etc.

 
> >There are already many ways to add defines. Adding another one would make it 
> >harder for newbies.  
> Is there some method to make a global define that is in the program itself?   
> I don't see how having options available makes anything harder for anyone, 
> they can just not use such features.

If someone else tries to understand your program he has to learn
your way. Too many options for the same thing can be a burden.
Especially when trying to find out why a macro was not defined.

 
>[...]
> Thanks for explaining that.  It looks like I can define where my units are 
> with fpc.cfg as well and then I won't need to keep putting them on the 
> command line.   If I put an fpc.cfg in a specific directory along with my 
> program to be compiled, will the one in that directory override the one in 
> \FPC\3.0.2\bin\i386-win32 ?

fpc takes the first it finds. You can see where fpc searches for configs using 
the -vt flag.
Alternatively you can pass @your.cfg to add a config.

 
> I'm wondering if I am missing something with reference to 'projects' is that 
> a Lazarus thing?   How are 'projects' defined?

Many IDEs have "projects". Lazarus too. They contain build options and
other stuff. The FPC IDE does not call it "project", but its
local fpc.cfg, fp.ini and fp.dsk files have a similar purpose.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Tomas Hajny
On Thu, June 15, 2017 13:57, James Richters wrote:
>>The idea is that you have one project per program. You can compile them
>> randomly without changing anything.
>
> I don't understand what you mean by 'one project per program' ?  I only
> have programs that I have sorted in sub directories.  I normally use the
> Freepascal text IDE to compile them, and sometimes the command line.   I
> might want to have ProgramA.pas have one define and ProgramB.pas have
> another, both using the same unit, is there some method to do that?

Yes:

1) Have sources of the two programs in different folders (directories) and
start the text-mode IDE in the respective folder depending on the
"project" / program you intend to build.

2) Set the compiler defines as necessary for the respective "project"
(i.e. differently for ProgramA when started from directory of ProgramA and
for ProgramB when started from directory of ProgramB) - Options ->
Compiler -> Conditional defines. By default, the configuration is
automaticaly saved when exiting the IDE.

3) Make sure you always rebuild the unit depending on the program you want
to compile (Compile -> Build). Obviously, this requires the source file of
the unit to be available for the compiler (i.e. in one of paths in Options
-> Directories -> Unit directories).


>>There are already many ways to add defines. Adding another one would make
>> it harder for newbies.
> Is there some method to make a global define that is in the program
> itself?   I don't see how having options available makes anything harder
> for anyone, they can just not use such features.

The hard thing is for the user to understand differences among the
available options and their implications.

Defines have impact only when compiling the particular source code. Having
a 'global define' in a program could never have impact to a unit which
might be already compiled using different defines at the moment the
particular program is compiled. One of possible solutions for this is
having a 'global include file' which is included in all the relevant units
and the program, the other is outlined above (defines stored in the
compiler / IDE configuration file).


>>If you want a compiler define for all projects, then simply add that
>> define in your fpc.cfg file. That is a "global options" file. I trust
>> those will take effect even if you use the FPC Text IDE, because it is
>> the fpc.exe binary that reads the fpc.cfg file and gets default settings
>> from there.

Not quite - the text-mode IDE doesn't invoke fpc.exe binary (it has the
compiler built-in) and it passes the options as defined in the respective
IDE dialogs.


> Thanks for explaining that.  It looks like I can define where my units are
> with fpc.cfg as well and then I won't need to keep putting them on the
> command line.   If I put an fpc.cfg in a specific directory along with my
> program to be compiled, will the one in that directory override the one in
> \FPC\3.0.2\bin\i386-win32 ?

Yes (if starting the _compiler_ in that directory). If using the IDE, you
can do the same with the fp.cfg file.


> I'm wondering if I am missing something with reference to 'projects' is
> that a Lazarus thing?   How are 'projects' defined?

Yes, projects are 'a Lazarus thing'. However, you can achieve a similar
effect with local options and configuration files for the text-mode IDE
(you just need to use different directories for different 'projects').

Hope this helps

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread James Richters
>The idea is that you have one project per program. You can compile them 
>randomly without changing anything.

I don't understand what you mean by 'one project per program' ?  I only have 
programs that I have sorted in sub directories.  I normally use the Freepascal 
text IDE to compile them, and sometimes the command line.   I might want to 
have ProgramA.pas have one define and ProgramB.pas have another, both using the 
same unit, is there some method to do that?

>There are already many ways to add defines. Adding another one would make it 
>harder for newbies.
Is there some method to make a global define that is in the program itself?   I 
don't see how having options available makes anything harder for anyone, they 
can just not use such features.

>If you want a compiler define for all projects, then simply add that define in 
>your fpc.cfg file. That is a "global options" file. I trust those will take 
>effect even if you use the FPC Text IDE, because it is the fpc.exe binary that 
>reads the fpc.cfg file and gets default settings from there.

Thanks for explaining that.  It looks like I can define where my units are with 
fpc.cfg as well and then I won't need to keep putting them on the command line. 
  If I put an fpc.cfg in a specific directory along with my program to be 
compiled, will the one in that directory override the one in 
\FPC\3.0.2\bin\i386-win32 ?

I'm wondering if I am missing something with reference to 'projects' is that a 
Lazarus thing?   How are 'projects' defined?

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Mattias Gaertner
Sent: Thursday, June 15, 2017 6:55 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On Thu, 15 Jun 2017 06:37:41 -0400
"James Richters" <ja...@productionautomation.net> wrote:

>[...]
> I see, thanks for explaining.   For some reason, I was thinking it was 
> optional to put it in the compiler, but I could also put it in the program.
> Is there no way to set a global define in each program so I could have 
> several programs defined differently and randomly compile them without 
> changing any settings?  

The idea is that you have one project per program. You can compile them 
randomly without changing anything.


> It seems some method of doing that would be very useful... but maybe not easy 
> to implement... I suppose it probably compiles all the units first then the 
> main program, so putting anything in the main program wouldn't be seen until 
> it was too late.

There are already many ways to add defines. Adding another one would make it 
harder for newbies.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 11:37, James Richters wrote:

 Maybe include Freetype32.dll and Freetype64.dll to make it very
clear.


That was exactly what I had in mind.


the program. Is there no way to set a global define in each program
so I could have several programs defined differently and randomly
compile them without changing any settings?


If you want a compiler define for all projects, then simply add that 
define in your fpc.cfg file. That is a "global options" file. I trust 
those will take effect even if you use the FPC Text IDE, because it is 
the fpc.exe binary that reads the fpc.cfg file and gets default settings 
from there.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Mattias Gaertner
On Thu, 15 Jun 2017 06:37:41 -0400
"James Richters"  wrote:

>[...]
> I see, thanks for explaining.   For some reason, I was thinking it was 
> optional to put it in the compiler, but I could also put it in the program.
> Is there no way to set a global define in each program so I could have 
> several programs defined differently and randomly compile them without 
> changing any settings?  

The idea is that you have one project per program. You can compile them
randomly without changing anything.


> It seems some method of doing that would be very useful... but maybe not easy 
> to implement... I suppose it probably compiles all the units first then the 
> main program, so putting anything in the main program wouldn't be seen until 
> it was too late.

There are already many ways to add defines. Adding another one would
make it harder for newbies.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread James Richters
>True. I'll include a 64-bit version too.

That would be great, because I don't have a clue where this 64bit version I 
found came from, what version it is, and things like that.  
Maybe include Freetype32.dll and Freetype64.dll to make it very clear.

>That is why I said you must put it in your Project's Compiler Settings instead 
>using your IDE of choice 
>(or via the command line when calling fpc.exe binary). That way the define is 
>active for all units of your project.

I see, thanks for explaining.   For some reason, I was thinking it was optional 
to put it in the compiler, but I could also put it in the program.
Is there no way to set a global define in each program so I could have several 
programs defined differently and randomly compile them without changing any 
settings?  
It seems some method of doing that would be very useful... but maybe not easy 
to implement... I suppose it probably compiles all the units first then the 
main program, so putting anything in the main program wouldn't be seen until it 
was too late.

James


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Thursday, June 15, 2017 3:19 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-15 02:40, James Richters wrote:
> That is what I thought should happen, but I put {$DEFINE 
> AGG2D_USE_FREETYPE}
>
> I don't know why the define isn't making it to the unit.  Do I need to 
> do something else?

Compiler defines defined with the $DEFINE directive is per unit only.

That is why I said you must put it in your Project's Compiler Settings instead 
using your IDE of choice (or via the command line when calling fpc.exe binary). 
That way the define is active for all units of your project.


Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 02:55, Stefan V. Pantazi wrote:

I think you need to use a global define passing a -d??? parameter
(-dAGG2D_USE_FREETYPE) to the compiler. Just adding it to a unit only
defines for that unit



The above statement is 100% correct.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-15 Thread Graeme Geldenhuys

On 2017-06-15 02:40, James Richters wrote:

That is what I thought should happen, but I put {$DEFINE
AGG2D_USE_FREETYPE}

I don't know why the define isn't making it to the unit.  Do I need
to do something else?


Compiler defines defined with the $DEFINE directive is per unit only.

That is why I said you must put it in your Project's Compiler Settings 
instead using your IDE of choice (or via the command line when calling 
fpc.exe binary). That way the define is active for all units of your 
project.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Stefan V. Pantazi
I think you need to use a global define passing a -d??? parameter 
(-dAGG2D_USE_FREETYPE) to the compiler. Just adding it to a unit only 
defines for that unit and to any file included in that one unit.


On 06/14/2017 09:40 PM, James Richters wrote:

The font rendering should all be controlled by compiler defines. You don't need 
to modify the unit to make it work.
Simply add the correct define in your project's Compiler Settings and recompile 
the code.


That is what I thought should happen, but I put
{$DEFINE AGG2D_USE_FREETYPE}

In my program under
{$mode objfpc}{$H+}

I still get:
FreeType: FALSE  Win32 True Type: TRUE

But if I uncomment
{$DEFINE AGG2D_USE_FREETYPE}
In agg_2D.pas

It's the only way I can get
FreeType: TRUE  Win32 True Type: FALSE

I don't know why the define isn't making it to the unit.  Do I need to do 
something else?   It's as if it's being un-defined somewhere else but I don't 
know where.. maybe the same place that is {$DEFINE AGG2D_USE_WINFONTS} because 
that is defiantly being set somewhere before the agg_2D.Pas unit and the only 
way to not get an error is for me to have this at the top of agg_2D.pas

{$IFDEF AGG2D_USE_FREETYPE }
 {$UNDEF AGG2D_USE_WINFONTS}
{$ENDIF }


And if you look in the "develop" branch of fpGUI, there is an even later
AggPas version - last updated a month ago.


Maybe I should go get this.. maybe some of these things are fixed already

Thank you for the help with this.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



--
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
>The font rendering should all be controlled by compiler defines. You don't 
>need to modify the unit to make it work.
>Simply add the correct define in your project's Compiler Settings and 
>recompile the code. 

That is what I thought should happen, but I put 
{$DEFINE AGG2D_USE_FREETYPE}

In my program under 
{$mode objfpc}{$H+} 

I still get:
FreeType: FALSE  Win32 True Type: TRUE

But if I uncomment 
{$DEFINE AGG2D_USE_FREETYPE} 
In agg_2D.pas

It's the only way I can get
FreeType: TRUE  Win32 True Type: FALSE

I don't know why the define isn't making it to the unit.  Do I need to do 
something else?   It's as if it's being un-defined somewhere else but I don't 
know where.. maybe the same place that is {$DEFINE AGG2D_USE_WINFONTS} because 
that is defiantly being set somewhere before the agg_2D.Pas unit and the only 
way to not get an error is for me to have this at the top of agg_2D.pas

{$IFDEF AGG2D_USE_FREETYPE }
 {$UNDEF AGG2D_USE_WINFONTS}
{$ENDIF }

>And if you look in the "develop" branch of fpGUI, there is an even later 
>AggPas version - last updated a month ago.

Maybe I should go get this.. maybe some of these things are fixed already

Thank you for the help with this.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Graeme Geldenhuys

On 2017-06-14 19:15, James Richters wrote:

testing it are using the same thing, and people can have programs
that use either unit side by side without remembering how to modify /
unmodify a unit to make it work.


The font rendering should all be controlled by compiler defines. You 
don't need to modify the unit to make it work. Simply add the correct 
define in your project's Compiler Settings and recompile the code. If 
you know you are only every going to use one font render engine, then 
you can obviously modify the unit to make the default more to your liking.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Graeme Geldenhuys

On 2017-06-14 19:15, James Richters wrote:

Here is what I found out... Freetype.dll included in
fpgui_src_1.4.1.zip indeed does not have a dependency for
msvcr71.dll...


Yup, that's what I thought. :)



however,  it only works if I compile with Win32.


True. I'll include a 64-bit version too.


Speaking of the AggPas in fpGUI only:
  As for the $DEFINE and $IFDEF comments. When you toggle one font 
renderer (or disable it completely), then the other defines should have 
been undefined. That's how it used to work. Maybe somewhere that go 
broken. I'll do some testing and fix anything that is needed. Thanks for 
mentioning it.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Graeme Geldenhuys

On 2017-06-14 16:37, James Richters wrote:

I was able to finally compile and run the test program for Win64.


Excellent news!



As for AggPas. I use the version of AggPas that is included with
fpGUI. I simply make sure the path to AggPas is specified in the


There are 3 forks of AggPas that I know of, and the one included with 
fpGUI is the most maintained version (features and bug fixes).




Previously I was using the only version of AggPas I could find by
doing an internet search which I downloaded from here:
http://www.crossgl.com/aggpas/aggpas-download.htm then downloaded
AggPas24-rm3.zip


Ah, that would explain it. That is the original and FINAL release of 
AggPas by Milano from many years ago. It doesn't support 64-bit, doesn't 
support FreeBSD and had some bugs.


All those issues have been resolved in the AggPas included with fpGUI.



So it looks like AggPas24-rm3.zip from
http://www.crossgl.com/aggpas/aggpas-download.htm was last updated in
2008, while FPGUI was updated in 2015 and the version there has had
some changes so it is now beyond 24-rm3.


And if you look in the "develop" branch of fpGUI, there is an even later 
AggPas version - last updated a month ago.




Very confusing.  Maybe
AggPas is not being maintained anymore at
http://www.crossgl.com/aggpas ?


Yes, it is a bit confusing. No, the original AgPass from the crossgl.com 
website is not being maintained for many years.


I think you main a valid point in your other mail about the unit header 
comments. I'll update the header comments in fpGUI repository and make 
sure that it mentions that it is beyond the origin 2.4-rm3 release.


ps:
  And if you wondered why I don't have AggPas in its own repository?
  AggPas is/has been integrated into fpGUI and is becoming the default
  renderer for fpGUI's Canvas class. So it's a critical dependency
  (and at the time I didn't know about Git Submodules). At least
  I kept all the AggPas code in its own directory, but in hindsight,
  I should probably have named that directory "render/aggpas/" and not
  "render/software/". Umm, I might just change that before the
  next fpGUI release.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
I finally got freetype to work with AggPas, but I had to make a few changes.  I 
am wondering if there is a way to submit a request for changes so they will be 
part of the next release?

Here is what I found out... 
Freetype.dll included in fpgui_src_1.4.1.zip indeed does not have a dependency 
for msvcr71.dll... however,  it only works if I compile with Win32.

I did some searching and came up with something called libfreetype-6.dll listed 
as a 64bit Freetype library, so I copied that over and renamed it to 
freetype.lib, and now my Win64 program uses it and works... but as expected, 
the Win32 program no longer works.  

So I did some digging and fount 'freetype.dll' being assigned in 
agg_font_freetype_lib.pas on line 42 as follows:
-
const
{$IFDEF WINDOWS }
  ft_lib = 'freetype.dll';
{$ENDIF }

// Linux, FreeBSD etc.
{$if defined(UNIX) and not defined(darwin)}
  ft_lib = 'freetype';
{$ENDIF }

// Mac OS X
{$ifdef darwin}
  ft_lib = 'libfreetype';
{$ENDIF }
-
So I changed the Windows section to:
{$IFDEF WINDOWS }
{$IFDEF CPU64 }
  ft_lib = 'libfreetype-6.dll';
{$Else }
  ft_lib = 'freetype.dll';
{$ENDIF }
{$ENDIF }

Now if I compile it Win64 it uses the 64bit library and if I compile it Win32 
it uses the 32bit library, this way I can just randomly create whatever type 
program I want and get the correct library.   I suppose something similar would 
be needed for other platforms but have no way to test it.

Also I had issues with using freetype at all.  I used 
Writeln('FreeType: ',Agg2DUsesFreeType,'  Win32 True Type: 
',Agg2DUsesWin32TrueType); 
To show which font method was being used and found my program was using win32 
true type fonts

So I went to Agg_2D.pas on line 25 and found this:

// With this define uncommented you can use FreeType font engine
{ $DEFINE AGG2D_USE_FREETYPE }

It took me a while to figure out that the space between ( and $ was making this 
into a comment,  it would have been more clear to comment it out like:
//{$DEFINE AGG2D_USE_FREETYPE}  

But in any case I did figure it out and uncommented it,  but then I could not 
compile it because of:
agg_2D.pas(142,15) Error: Duplicate identifier "FontEngine"

So Agg_2D.pas line 138 - 143 are:
{$IFDEF AGG2D_USE_FREETYPE }
 FontEngine = font_engine_freetype_int32;
{$ENDIF }
{$IFDEF AGG2D_USE_WINFONTS}
 FontEngine = font_engine_win32_tt_int32;
{$ENDIF }

The only way the FontEngine = font_engine_win32_tt_int32; on line 142 could 
cause this error is if both  AGG2D_USE_WINFONTS and  AGG2D_USE_FREETYPE were 
defined.  I looked around and could not find where AGG2D_USE_WINFONTS was 
defined, but it seems obvious that both cannot be defined at once so I changed 
from line 25 in Agg_2D.pas to this:
// With this define uncommented you can use FreeType font engine
//{$DEFINE AGG2D_USE_FREETYPE}

{$IFDEF AGG2D_USE_FREETYPE }
  {$UNDEF AGG2D_USE_WINFONTS}
{$ENDIF }

And now if I run it as above I get Win32 true type fonts and if I comment out 
the freetype define I get freetype fonts.

I noticed that with the freetype define comment out, adding it to my program 
could not make it work.  I would prefer a method that did not involve modifying 
the Agg_2D unit to change which font package to use.

Also,  I have copied Agg_2D.pas to Agg_2D_RBG565.pas and modified that one as 
needed for ptcgraph.  I wonder if it would be beneficial to add this modified 
version of the unit to the development system so eventually it will be included 
in the official release.  That way everyone working on it and / or testing it 
are using the same thing, and people can have programs that use either unit 
side by side without remembering how to modify / unmodify a unit to make it 
work.I'm not sure where the proper place is to submit things like this, but 
I would be happy to contribute these changes if possible.

James



-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
James Richters
Sent: Wednesday, June 14, 2017 11:54 AM
To: 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

All this has me wondering about the freetype.dll version.  I've been using 
freetype.dll that I found in AggPas24-rm3.zip modified 9/17/2007 I notice there 
is another one in fpgui_src_1.4.1.zip in the 
fpgui-1.4.1\extras\freetype_windows directory modified 12/9/2012  Is this the 
best version to use?  

I was hoping to figure out a way to not have the dependency of msvcr71.dll I 
tried going all over https://www.freetype.org and even downloaded ft28.zip from 
there and tried to make sense of it, but just got more confused I haven't tried 
the version of freetype.dll included with fpgui yet, I thought I would just ask 
first

James

___
fpc-pascal maillis

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
All this has me wondering about the freetype.dll version.  I've been using 
freetype.dll that I found in AggPas24-rm3.zip modified 9/17/2007
I notice there is another one in fpgui_src_1.4.1.zip in the 
fpgui-1.4.1\extras\freetype_windows directory modified 12/9/2012  Is this the 
best version to use?  

I was hoping to figure out a way to not have the dependency of msvcr71.dll
I tried going all over https://www.freetype.org and even downloaded ft28.zip 
from there and tried to make sense of it, but just got more confused
I haven't tried the version of freetype.dll included with fpgui yet, I thought 
I would just ask first

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
I was able to finally compile and run the test program for Win64.   I wanted to 
change only one thing at a time so I could figure out what exactly the problem 
was.  The first thing I tried was to use the exact version of AggPas Graeme 
used.

>As for AggPas. I use the version of AggPas that is included with fpGUI. 
>I simply make sure the path to AggPas is specified in the project compiler 
>settings, which in the above command line parameter is:
>c:\devel\fpgui\src\corelib\render\software

Previously I was using the only version of AggPas I could find by doing an 
internet search which I downloaded from here:
http://www.crossgl.com/aggpas/aggpas-download.htm then downloaded 
AggPas24-rm3.zip 

So I removed that version and downloaded fpgui_src_1.4.1.zip from:
https://sourceforge.net/projects/fpgui/files/fpGUI/1.4.1/

I extracted it to my H: Drive and tested it out.
I did not change my path for this test so I just put in paths to everything and 
ran it from the H:\FPC64\3.0.2\x86_64-win64\bin directory then executed the 
following command line:
fpc -Fu..\units\$fpctarget\* -FuH:\fpgui-1.4.1\src\corelib\render\software 
J:\programming\Gcode\Graphics\aggpas_ptcgraph_output.pas

The compile was successful and the Win64 version of the program ran fine.

So just for fun, I replaced the aggpas units in my original setup with the ones 
from fpgui_src_1.4.1.zip and tried it the original way I was doing it with the 
cross compiler and the command:
fpc -FuJ:\Programming\FPC\3.0.2\units\$fpctarget\* -Px86_64 
aggpas_ptcgraph_output.pas 
This was also successful, so I tried a few other sample programs and they all 
seem to work as both Win32 and Win64

So I was wondering, why would this be?  So I looked at this:
>While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 press Ctr 
>and click on ptrcomp. It should open agg_basics.pas, the comment may apply to 
>your situation.

And did a compare between agg_basics from AggPas24-rm3.zip and agg_basics from 
fpgui_src_1.4.1.zip and noticed they are NOT the same.  They both indicate they 
are the same by the comments at the top 
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3) 

But the version from AggPas24-rm3.zip has
// Pascal's pointer-in-an-array-access helper structures
 p32_ptr = ^p32;
 p32 = record
   case integer of
1 : (ptr : pointer );

   {$IFDEF CPU64 }
2 : (int : system.int64 );

   {$ELSE }
2 : (int : integer );

   {$ENDIF }

  end;

while the version from fpgui_src_1.4.1.zip has
// Pascal's pointer-in-an-array-access helper structures
 p32_ptr = ^p32;
 p32 = record
   case integer of
1 : (ptr : pointer );
2 : (int : ptrcomp );
  end;

There are also several other differences in the 2 files.   

So it looks like AggPas24-rm3.zip from 
http://www.crossgl.com/aggpas/aggpas-download.htm was last updated in 2008, 
while
FPGUI was updated in 2015 and the version there has had some changes so it is 
now beyond 24-rm3.  Very confusing.  Maybe AggPas is not being maintained 
anymore at http://www.crossgl.com/aggpas ?

Anyway Thank you to everyone for helping get to the bottom of this!  


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Wednesday, June 14, 2017 8:29 AM
To: fpc-pascal@lists.freepascal.org
Cc: James Richters <ja...@productionautomation.net>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-14 11:57, James Richters wrote:
> I've downloaded the zip file and extracted it to H:\FPC64.   But now
> I have a few questions to attempt to duplicate a successful 64bit 
> compile.

Two steps are required - sorry, I forgot to mention that in my previous post 
(though I did to the person i created this zip for originally).

1) I find it always useful to have the \bin\ directory in my PATH so that 
the fpc.exe executable can be run from anywhere.

2) You need to adjust the fpc.cfg file (located in the 'bin' directory) to 
match your install path. My path was:

c:\lazarus\fpc\3.0.2\x86_64-win64

Back in FPC 2.4.x I installed Lazarus which included FPC, which in turn 
installed the FPC under the c:\lazarus\fpc\ directory. Ever since every FPC 
update, I just stuck to that install location. So you don't need to have it 
like this obviously.


> Maybe it isn't valid to use the IDE with Win64?  I sure wish it would
> work.   I like and prefer the FPC text IDE.

The FPC Text IDE (64-bit) runs just fine here under Windows 7 64-bit. 
See attached screenshot. Even mouse support works inside the Text IDE.

I mostly use MSEide for all my console, web and fpGUI related programming. I 
created some custom project templates and away I go. 
Lazarus has some nice editor features, but is often buggy and the Lazarus 
Package system just doesn't work for me. With MSEide I use global (or per 
project) path macros instead. This gives much more reliable compilations.

Here is the

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
>> I also wonder if this is a windows 10 frootllooopy weirdness thing (it 
>> wouldn't be the first).  Can you just email me the exe file zipped and 
>> I'll just try to run it here?  Then I will know if it's a compiler 
>> issue or an OS issue

>I assume you mean the executable of the ptcgraph+aggpas demo? I'll do so in a 
>private email.

Thanks for mailing the demo executable.  I'm happy to report that it does run 
fine on my system as well (Windows 10 x64)
So there must be something different in the way I am compiling it that is 
causing the problem.

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
Thanks for all the info, I will try to get it working.

>I assume you mean the executable of the ptcgraph+aggpas demo? I'll do so in a 
>private email.
Yes, please.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Graeme Geldenhuys

On 2017-06-14 11:57, James Richters wrote:

I've downloaded the zip file and extracted it to H:\FPC64.   But now
I have a few questions to attempt to duplicate a successful 64bit
compile.


Two steps are required - sorry, I forgot to mention that in my previous 
post (though I did to the person i created this zip for originally).


1) I find it always useful to have the \bin\ directory in my PATH 
so that the fpc.exe executable can be run from anywhere.


2) You need to adjust the fpc.cfg file (located in the 'bin' directory) 
to match your install path. My path was:


   c:\lazarus\fpc\3.0.2\x86_64-win64

Back in FPC 2.4.x I installed Lazarus which included FPC, which in turn 
installed the FPC under the c:\lazarus\fpc\ directory. Ever since every 
FPC update, I just stuck to that install location. So you don't need to 
have it like this obviously.




Maybe it isn't valid to use the IDE with Win64?  I sure wish it would
work.   I like and prefer the FPC text IDE.


The FPC Text IDE (64-bit) runs just fine here under Windows 7 64-bit. 
See attached screenshot. Even mouse support works inside the Text IDE.


I mostly use MSEide for all my console, web and fpGUI related 
programming. I created some custom project templates and away I go. 
Lazarus has some nice editor features, but is often buggy and the 
Lazarus Package system just doesn't work for me. With MSEide I use 
global (or per project) path macros instead. This gives much more 
reliable compilations.


Here is the command line equivalent of what my MSEide project does for 
the ptcgraph + aggpas demo.


C:\lazarus\fpc\3.0.2\x86_64-win64\bin\fpc.exe 
-oaggpas_ptcgraph_output.exe -Fuc:\devel\fpgui\src\reportengine 
-Fuc:\devel\fpgui\src\corelib\render\software 
-Fic:\devel\fpgui\src\corelib\render\software -Fic:\devel\fpgui\src 
-Fuc:\devel\fpgui\src\corelib\gdi -Fic:\devel\fpgui\src\corelib\gdi 
-Fuc:\devel\fpgui\src\gui -Fuc:\devel\fpgui\src\corelib -l -Mobjfpc -Sh 
-Sc -Si -gl -O- -FUunits -viewnh aggpas_ptcgraph_output.pas



As for AggPas. I use the version of AggPas that is included with fpGUI. 
I simply make sure the path to AggPas is specified in the project 
compiler settings, which in the above command line parameter is:


   c:\devel\fpgui\src\corelib\render\software

FPC then compiles all units as it needs them, and I always output the 
compiled units into a project specific "units" directory (the -FUunits 
command line parameter seen above). I don't like mixing *.pas and 
*.o;*.ppu files in the same directories.




I also wonder if this is a windows 10 frootllooopy weirdness thing
(it wouldn't be the first).  Can you just email me the exe file
zipped and l'll just try to run it here?  Then I will know if it's a
compiler issue or an OS issue


I assume you mean the executable of the ptcgraph+aggpas demo? I'll do so 
in a private email.




Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread James Richters
>Strange, as it works perfectly here. I compiled FPC 3.0.2 for win64 (I always 
>do that for Win64 - I never use the cross compiler). 
>Somebody else (I can't remember who) asked for a native win64 windows 
>compiler, and I zipped up the one I had. It is still available for download 
>from here...

I've downloaded the zip file and extracted it to H:\FPC64.   But now I have a 
few questions to attempt to duplicate a successful 64bit compile.  It's 
probably better to ask than to make a mess of things by doing it wrong.
Starting with the native win64 windows compiler I just downloaded,  how do I 
install the aggpas units?
How do you use this to compile the example successfully?  IDE? command line?  
Do I need to define unit directories somewhere?
Any other configurations or setups I need to do?
I notice there is a 64bit version of the IDE and in there under Options > 
Compiler > Processor the CoreI and Athlon64 are listed, so it seemed
Like it should just work (although I don't know how these should be set)

I tried to use the IDE to compile one of my simple programs but I get
Program generated a RTE 217
at address $.
Save your sources and restart the IDE.

Then after clicking OK

The IDE generated an internal error
and will now be closed.

Maybe it isn't valid to use the IDE with Win64?  I sure wish it would work.   I 
like and prefer the FPC text IDE.

I also wonder if this is a windows 10 frootllooopy weirdness thing (it wouldn't 
be the first).  Can you just email me the exe file zipped and l'll just try to 
run it here?  Then I will know if it's a compiler issue or an OS issue

James
  

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Wednesday, June 14, 2017 5:17 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-14 01:25, James Richters wrote:
> I have just installed Lazarus but still can't get the 
> aggpas_ptcgraph_output.pas sample program to run when compiled for 
> x64. Here is what I have done.


Strange, as it works perfectly here. I compiled FPC 3.0.2 for win64 (I always 
do that for Win64 - I never use the cross compiler). Somebody else (I can't 
remember who) asked for a native win64 windows compiler, and I zipped up the 
one I had. It is still available for download from here...

http://geldenhuys.co.uk/~graemeg/fpc-3.0.2-win64.7z


I then compiled your sample program. It works and runs perfectly under Windows 
7 (64-bit). See the my second private email where I attached a screenshot. I 
don't have a later Windows version to test on.

The only mods I made:
   - modified agg_2D.pas so the constructor takes a pixfmt parameter.
   - flipped the Y-axis in the example program.

The pixel channel order is still an issue though - Red and Blue channels need 
to be swapped.


Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-14 Thread Graeme Geldenhuys

On 2017-06-14 01:25, James Richters wrote:

I have just installed Lazarus but still can't get the
aggpas_ptcgraph_output.pas sample program to run when compiled for
x64. Here is what I have done.



Strange, as it works perfectly here. I compiled FPC 3.0.2 for win64 (I
always do that for Win64 - I never use the cross compiler). Somebody
else (I can't remember who) asked for a native win64 windows compiler,
and I zipped up the one I had. It is still available for download from
here...

   http://geldenhuys.co.uk/~graemeg/fpc-3.0.2-win64.7z


I then compiled your sample program. It works and runs perfectly under
Windows 7 (64-bit). See the my second private email where I attached a
screenshot. I don't have a later Windows version to test on.

The only mods I made:
  - modified agg_2D.pas so the constructor takes a pixfmt parameter.
  - flipped the Y-axis in the example program.

The pixel channel order is still an issue though - Red and Blue channels
need to be swapped.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread Stefan V. Pantazi
Yes, it is puzzling. Different pointer sizes, compilers, OS, 32/64 bit 
library dependencies, can be potential causes.


Again, note that I compiled the example on a CentOS 7, 64bit Linux with 
Lazarus 1.5 + fpc 3.0.1


I can also confirm that the test program compiles and works fine on 
Ubuntu 16.04 64bit, with Lazarus 1.7 + fpc 3.1.1



On 06/13/2017 10:16 PM, James Richters wrote:

but I don't know what I can do about it and why you are able to cross 
compile for win64 and it works.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
>If you are already on a win64 machine then your default target CPU should 
>already be x86_64. why do you need fpc-3.0.2-cross-i386-win32-win64?
Correction:  
I start with fpc-3.0.2.i386-win32 because there is no precompiled version for 
win64 of freepascal I tried to compile it myself is it's just a confusing mess 
that I can't get to work.
So I then need to install fpc-3.0.2-cross-i386-win32-win64 to compile x64 with 
the above fpc-3.0.2.i386-win32 running on my x64 machine.

With Lazarus I am able to do it the other way around, I install
lazarus-1.6.4-fpc-3.0.2-win64.exe so from there I can compile x64 programs, 
then install 
lazarus-1.6.4-fpc-3.0.2-cross-i386-win32-win64.exe so I can also compile Win32 
programs with Lazarus.

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
James Richters
Sent: Tuesday, June 13, 2017 10:16 PM
To: 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

>It is unclear to me whether you are on a win32 or win64 OS?
I am on Windows 10 x64 OS

>If you are already on a win64 machine then your default target CPU should 
>already be x86_64. why do you need fpc-3.0.2-cross-i386-win32-win64?
fpc-3.0.2-cross-i386-win32-win64 is to be able to compile as a win32 program on 
a win64 machine.   I installed that so I could compile as win32 for comparison. 
 The test program works if compiled with Lazarus  for win32 but not win64

>While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 press Ctr 
>and click on ptrcomp. It should open agg_basics.pas, the comment may apply to 
>your situation.
I was able to follow this and get to the comment in agg_basics, I read the 
comment that indicates some difference and possible problem with pointers on 
win64 but I don't know what I can do about it and why you are able to cross 
compile for win64 and it works.   I wonder if this is an issue with Freepascal 
3.0.2, and aggpas hasn't been fixed for it yet and I need to use Freepascal 
3.0.1 to get it to work?

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Tuesday, June 13, 2017 9:25 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 press Ctr 
and click on ptrcomp. It should open agg_basics.pas, the comment may apply to 
your situation.

It is unclear to me whether you are on a win32 or win64 OS? If you are already 
on a win64 machine then your default target CPU should already be x86_64. why 
do you need fpc-3.0.2-cross-i386-win32-win64?


On 06/13/2017 08:25 PM, James Richters wrote:
>> Noting your problems with compilation, you may want to consider using 
>> Lazarus IDE as well.
>
> I have just installed Lazarus but still can't get the 
> aggpas_ptcgraph_output.pas sample program to run when compiled for x64.
> Here is what I have done.
>
> Downloaded and installed lazarus-1.6.0-fpc-3.0.0-win64.exe and 
> accepted all defaults Downloaded and installed 
> lazarus-1.6.4-fpc-3.0.2-cross-i386-win32-win64.exe and accepted the default 
> install directory.
> Copied aggpas to C:\lazarus\fpc\3.0.2\units\i386-win32
> Copied aggpas to C:\lazarus\fpc\3.0.2\units\x86_64-win64
>
> Opened a sample program the uses just ptcgraph, when it asked to 
> create a project I said yes then selected 'Program' from the list I 
> was able to compile and run it with options for OS win32 CPU i386 as 
> well as OS  win64 CPU x86_64 and it ran fine with both versions I opened 
> aggpas_ptcgraph_output.pas the same way and selected program.  If I select OS 
> win32 CPU i386 it compiles and runs fine, no problems When I select OS  win64 
> CPU x86_64 and try to run it, it opens both the console window and graphics 
> window, then I get an error box reading:
>
> Project aggpas_ptcgraph_output raised exception class 'external: SIGSEGV'
> In file 'C:\lazarus\fpc\3.0.2\u..\agg_rasterizer_scanline_aa.pas' at 
> line 611 while cell_aa_ptr_prt(ptrcomp(j) + 1 * 4^^.x<J^.x do
>
> Any ideas why this is happening?
>
> James
>
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

--
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
>It is unclear to me whether you are on a win32 or win64 OS?
I am on Windows 10 x64 OS

>If you are already on a win64 machine then your default target CPU should 
>already be x86_64. why do you need fpc-3.0.2-cross-i386-win32-win64?
fpc-3.0.2-cross-i386-win32-win64 is to be able to compile as a win32 program on 
a win64 machine.   I installed that so I could compile as win32 for comparison. 
 The test program works if compiled with Lazarus  for win32 but not win64

>While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 press Ctr 
>and click on ptrcomp. It should open agg_basics.pas, the comment may apply to 
>your situation.
I was able to follow this and get to the comment in agg_basics, I read the 
comment that indicates some difference and possible problem with pointers on 
win64 but I don't know what I can do about it and why you are able to cross 
compile for win64 and it works.   I wonder if this is an issue with Freepascal 
3.0.2, and aggpas hasn't been fixed for it yet and I need to use Freepascal 
3.0.1 to get it to work?

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Tuesday, June 13, 2017 9:25 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 press Ctr 
and click on ptrcomp. It should open agg_basics.pas, the comment may apply to 
your situation.

It is unclear to me whether you are on a win32 or win64 OS? If you are already 
on a win64 machine then your default target CPU should already be x86_64. why 
do you need fpc-3.0.2-cross-i386-win32-win64?


On 06/13/2017 08:25 PM, James Richters wrote:
>> Noting your problems with compilation, you may want to consider using 
>> Lazarus IDE as well.
>
> I have just installed Lazarus but still can't get the 
> aggpas_ptcgraph_output.pas sample program to run when compiled for x64.
> Here is what I have done.
>
> Downloaded and installed lazarus-1.6.0-fpc-3.0.0-win64.exe and 
> accepted all defaults Downloaded and installed 
> lazarus-1.6.4-fpc-3.0.2-cross-i386-win32-win64.exe and accepted the default 
> install directory.
> Copied aggpas to C:\lazarus\fpc\3.0.2\units\i386-win32
> Copied aggpas to C:\lazarus\fpc\3.0.2\units\x86_64-win64
>
> Opened a sample program the uses just ptcgraph, when it asked to 
> create a project I said yes then selected 'Program' from the list I 
> was able to compile and run it with options for OS win32 CPU i386 as 
> well as OS  win64 CPU x86_64 and it ran fine with both versions I opened 
> aggpas_ptcgraph_output.pas the same way and selected program.  If I select OS 
> win32 CPU i386 it compiles and runs fine, no problems When I select OS  win64 
> CPU x86_64 and try to run it, it opens both the console window and graphics 
> window, then I get an error box reading:
>
> Project aggpas_ptcgraph_output raised exception class 'external: SIGSEGV'
> In file 'C:\lazarus\fpc\3.0.2\u..\agg_rasterizer_scanline_aa.pas' at 
> line 611 while cell_aa_ptr_prt(ptrcomp(j) + 1 * 4^^.x<J^.x do
>
> Any ideas why this is happening?
>
> James
>
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

--
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread Stefan V. Pantazi
While in lazarus open agg_rasterizer_scanline_aa.pas, go ro line 611 
press Ctr and click on ptrcomp. It should open agg_basics.pas, the 
comment may apply to your situation.


It is unclear to me whether you are on a win32 or win64 OS? If you are 
already on a win64 machine then your default target CPU should already 
be x86_64. why do you need fpc-3.0.2-cross-i386-win32-win64?



On 06/13/2017 08:25 PM, James Richters wrote:

Noting your problems with compilation, you may want to consider using Lazarus 
IDE as well.


I have just installed Lazarus but still can't get the 
aggpas_ptcgraph_output.pas sample program to run when compiled for x64.
Here is what I have done.

Downloaded and installed lazarus-1.6.0-fpc-3.0.0-win64.exe and accepted all 
defaults
Downloaded and installed lazarus-1.6.4-fpc-3.0.2-cross-i386-win32-win64.exe and 
accepted the default install directory.
Copied aggpas to C:\lazarus\fpc\3.0.2\units\i386-win32
Copied aggpas to C:\lazarus\fpc\3.0.2\units\x86_64-win64

Opened a sample program the uses just ptcgraph, when it asked to create a 
project I said yes then selected 'Program' from the list
I was able to compile and run it with options for OS win32 CPU i386 as well as 
OS  win64 CPU x86_64 and it ran fine with both versions
I opened aggpas_ptcgraph_output.pas the same way and selected program.  If I 
select OS win32 CPU i386 it compiles and runs fine, no problems
When I select OS  win64 CPU x86_64 and try to run it, it opens both the console 
window and graphics window, then I get an error box reading:

Project aggpas_ptcgraph_output raised exception class 'external: SIGSEGV'
In file 'C:\lazarus\fpc\3.0.2\u..\agg_rasterizer_scanline_aa.pas' at line 611 
while cell_aa_ptr_prt(ptrcomp(j) + 1 * 4^^.x

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread Stefan V. Pantazi
Looks like it may be something specific to your setup. In my tests I 
used Lazarus 1.5 as IDE and fpc 3.0.1 on Linux. Crosscompiled example 
ran on Win7 64 bit. So there are already differences with your 
environment. Noting your problems with compilation, you may want to 
consider using Lazarus IDE as well. You get a debugger too.


One other thing that comes to mind is to be mindful of calls like this

  agg^.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);

If the default fill color is black, then the result will be a black 
window, albeit not unresponsive. Again, if your program hangs for some 
reason, a debugger may come in handy.


Stefan

On 06/13/2017 04:44 PM, James Richters wrote:

I've tested the example on 64 bit linux as a native application as well cross 
compiled for a x86_64 windows target. Worked fine in both Wine and on a Win64 
machine.



In my experience, the one dependency that AggPas has potential to fail may be 
related to the freetype library. If you plan to run your app on windows only, 
then you can turn freetype off and
AggPas will happily use windows font libraries. Search for the 
AGG2D_USE_FREETYPE define and comment it out.


I thought I would try to compile the example for x86_64, because I would 
eventually like to make my final program an x86_64 program.

When I compile it with the command:
fpc -Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' aggpas_ptcgraph_output.pas
it works fine.

When I try
fpc -Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' -Px86_64 
aggpas_ptcgraph_output.pas
it compiles fine with no errors, and it executes with no errors, however I do 
not get any output in either window at all, they are both just black, and 
unresponsive.

I've commented out the AGG2D_USE_FREETYPE for now, because I'm not sure if the 
freetype.dll I have will work on 64bit programs, and thought I would eliminate 
that as a possible issue.

I am using FPC v3.0.2 on a windows 10 x64 machine
I normally use the freepascal IDE to compile my programs, so I'm not too 
familiar with compiling from the command line.  I'm wondering if I am doing 
something wrong.

Also, is there some way to set a default for my units so I don't have to use 
Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' all the time?  If I don't use 
that, then it can't find any units, even though it's set in the directories 
with the IDE

I have some other sample programs that use ptcgraph (without AggPas) that do 
not have this issue, they compile as 64bit programs and run fine.  This seems 
to be something with using AggPas that appears to be causing the problem. I  
put in a writeln('test'); at the beginning of the program and it does do that, 
and I move ptcgraph.Rectangle(10,10,100,100); to before drawstuff(agg); I will 
get the rectangle on the graph screen.   So I thought I would try to narrow 
down what was happening by drawing different rectangles in the middle of the 
code like this:
  ptcgraph.Rectangle(30,30,200,200);
  agg^.clearAll(0, 0, 0);
  agg^.lineColor(0, 0, 0, 255);
  agg^.lineWidth(3);
  agg^.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
  ptcgraph.Rectangle(30,30,200,300);
  agg^.lineWidth(1);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
  ptcgraph.Rectangle(30,30,300,300);

I get the first rectangle right away, the second rectangle after 6 seconds, and 
the third after 6 more seconds.
I tried commenting out everything else, but I still never get the image from 
putimage();

I'm very confused by this and don't have a clue what could be wrong.  If I take 
out the -Px86_64 in the compile command line, the program runs as expected.  
Since Stefan said he compiled 64bit versions of the example program and it 
worked, I wonder why I am having this issue.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



--
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
>I've tested the example on 64 bit linux as a native application as well cross 
>compiled for a x86_64 windows target. Worked fine in both Wine and on a Win64 
>machine.

>In my experience, the one dependency that AggPas has potential to fail may be 
>related to the freetype library. If you plan to run your app on windows only, 
>then you can turn freetype off and
>AggPas will happily use windows font libraries. Search for the 
>AGG2D_USE_FREETYPE define and comment it out.

I thought I would try to compile the example for x86_64, because I would 
eventually like to make my final program an x86_64 program. 

When I compile it with the command:
fpc -Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' aggpas_ptcgraph_output.pas
it works fine.

When I try
fpc -Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' -Px86_64 
aggpas_ptcgraph_output.pas
it compiles fine with no errors, and it executes with no errors, however I do 
not get any output in either window at all, they are both just black, and 
unresponsive.

I've commented out the AGG2D_USE_FREETYPE for now, because I'm not sure if the 
freetype.dll I have will work on 64bit programs, and thought I would eliminate 
that as a possible issue.

I am using FPC v3.0.2 on a windows 10 x64 machine
I normally use the freepascal IDE to compile my programs, so I'm not too 
familiar with compiling from the command line.  I'm wondering if I am doing 
something wrong.

Also, is there some way to set a default for my units so I don't have to use 
Fu'J:\programming\fpc\3.0.2\units\$fpctarget\*' all the time?  If I don't use 
that, then it can't find any units, even though it's set in the directories 
with the IDE

I have some other sample programs that use ptcgraph (without AggPas) that do 
not have this issue, they compile as 64bit programs and run fine.  This seems 
to be something with using AggPas that appears to be causing the problem. I  
put in a writeln('test'); at the beginning of the program and it does do that, 
and I move ptcgraph.Rectangle(10,10,100,100); to before drawstuff(agg); I will 
get the rectangle on the graph screen.   So I thought I would try to narrow 
down what was happening by drawing different rectangles in the middle of the 
code like this:
  ptcgraph.Rectangle(30,30,200,200);
  agg^.clearAll(0, 0, 0);
  agg^.lineColor(0, 0, 0, 255);
  agg^.lineWidth(3);
  agg^.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
  ptcgraph.Rectangle(30,30,200,300);
  agg^.lineWidth(1);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
  ptcgraph.Rectangle(30,30,300,300);

I get the first rectangle right away, the second rectangle after 6 seconds, and 
the third after 6 more seconds.  
I tried commenting out everything else, but I still never get the image from 
putimage(); 

I'm very confused by this and don't have a clue what could be wrong.  If I take 
out the -Px86_64 in the compile command line, the program runs as expected.  
Since Stefan said he compiled 64bit versions of the example program and it 
worked, I wonder why I am having this issue.

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
Thanks for the help with this
> 1) the ideal way would be to specify the rgb order of a pixel format in the 
> Agg_2D constructor. The m_pixFormat 
> has a m_order field with the type order_type defined in agg_color.pas; have 
> not figured it yet

>2) knowing the R and B channels are swapped, you can do all your drawing with 
>colors there R and B are switched.
It sounds like it would be easier to figure out option 1.   That may also be 
better for compatibility if aggpas is updated in the future to be more 
compatible with ptcgraph.

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Tuesday, June 13, 2017 2:03 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

There is a minus sign in the call:

  agg^.attach(@graph_buffer.data, IMAGE_WIDTH, IMAGE_HEIGHT, -(IMAGE_WIDTH * 
RGB_WIDTH))

Removing it will flip the Y axis.

With regard to color, there may be two options:

1) the ideal way would be to specify the rgb order of a pixel format in the 
Agg_2D constructor. The m_pixFormat has a m_order field with the type 
order_type defined in agg_color.pas; have not figured it yet

2) knowing the R and B channels are swapped, you can do all your drawing with 
colors there R and B are switched.


Stefan


On 06/13/2017 12:42 PM, James Richters wrote:
> I've just realized that the red and blue channels are reversed.  The sample
> program aggpas_ptcgraph_output.pas has the star filled in with a red fade
> and a blue series of random lines while the original test.png file had a
> blue fade in the star with red random lines.   Also, the image is flipped on
> the Y axis compared to the original example. The small green square is in
> the upper left corner of test.png, but it is in the lower left corner of
> aggpas_ptcgraph_output.pas
>
> I've been able to duplicate the results of test.png by shifting the left 5
> bits 11 positions to the right and the right 5 bits 11 positions to the left
> and flipping the Y axis,  but I can only do that with putpixel and a nested
> loop, which is quite a bit slower than putimage.
>
> Any ideas how I can build the data correctly so putimage will work?
>
> James
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

-- 
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
>   Also, the image is flipped on
>the Y axis compared to the original example. The small green square is in the 
>upper left corner of test.png, but it is in the lower left corner of 
>aggpas_ptcgraph_output.pas

It appears there is some ambiguity on whether 0,0 should be the lower left of 
upper left, but 
I figured out how to flip the image on the Y axis:

agg^.attach(@graph_buffer.data, IMAGE_WIDTH, IMAGE_HEIGHT, -(IMAGE_WIDTH * 
RGB_WIDTH)); 
makes the image what I would consider upside down because
agg^.rectangle(10, 10, 50, 50); 
ends up in the lower left corner but
ptcgraph.Rectangle(10,10,100,100);
ends up in the upper right corner.

If I use 
agg^.attach(@graph_buffer.data, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH * 
RGB_WIDTH);
now both 
agg^.rectangle(10, 10, 50, 50); 
and
ptcgraph.Rectangle(10,10,100,100);
end up in the upper left corner with the 10,10 coordinates matching up

I still have not figured out how to switch red and blue bits around so 
putimage() will work.

James


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
James Richters
Sent: Tuesday, June 13, 2017 12:43 PM
To: 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

I've just realized that the red and blue channels are reversed.  The sample 
program aggpas_ptcgraph_output.pas has the star filled in with a red fade and a 
blue series of random lines while the original test.png file had a
blue fade in the star with red random lines.   Also, the image is flipped on
the Y axis compared to the original example. The small green square is in the 
upper left corner of test.png, but it is in the lower left corner of 
aggpas_ptcgraph_output.pas

I've been able to duplicate the results of test.png by shifting the left 5 bits 
11 positions to the right and the right 5 bits 11 positions to the left and 
flipping the Y axis,  but I can only do that with putpixel and a nested
loop, which is quite a bit slower than putimage.   

Any ideas how I can build the data correctly so putimage will work?

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread Stefan V. Pantazi

There is a minus sign in the call:

 agg^.attach(@graph_buffer.data, IMAGE_WIDTH, IMAGE_HEIGHT, 
-(IMAGE_WIDTH * RGB_WIDTH))


Removing it will flip the Y axis.

With regard to color, there may be two options:

1) the ideal way would be to specify the rgb order of a pixel format in 
the Agg_2D constructor. The m_pixFormat has a m_order field with the 
type order_type defined in agg_color.pas; have not figured it yet


2) knowing the R and B channels are swapped, you can do all your drawing 
with colors there R and B are switched.



Stefan


On 06/13/2017 12:42 PM, James Richters wrote:

I've just realized that the red and blue channels are reversed.  The sample
program aggpas_ptcgraph_output.pas has the star filled in with a red fade
and a blue series of random lines while the original test.png file had a
blue fade in the star with red random lines.   Also, the image is flipped on
the Y axis compared to the original example. The small green square is in
the upper left corner of test.png, but it is in the lower left corner of
aggpas_ptcgraph_output.pas

I've been able to duplicate the results of test.png by shifting the left 5
bits 11 positions to the right and the right 5 bits 11 positions to the left
and flipping the Y axis,  but I can only do that with putpixel and a nested
loop, which is quite a bit slower than putimage.

Any ideas how I can build the data correctly so putimage will work?

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



--
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-13 Thread James Richters
I've just realized that the red and blue channels are reversed.  The sample
program aggpas_ptcgraph_output.pas has the star filled in with a red fade
and a blue series of random lines while the original test.png file had a
blue fade in the star with red random lines.   Also, the image is flipped on
the Y axis compared to the original example. The small green square is in
the upper left corner of test.png, but it is in the lower left corner of
aggpas_ptcgraph_output.pas

I've been able to duplicate the results of test.png by shifting the left 5
bits 11 positions to the right and the right 5 bits 11 positions to the left
and flipping the Y axis,  but I can only do that with putpixel and a nested
loop, which is quite a bit slower than putimage.   

Any ideas how I can build the data correctly so putimage will work?

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-06 Thread James Richters
>How did you build/get freetype.dll?

I don't know how it was built, I swiped it from the AggPas24-rm3.zip file and 
it seemed to work.
I did find msvcr71.dll by searching my entire development pc hard drive and 
found it in C:\Program Files (x86)\StarWind Software\StarWind V2V Image 
Converter\lib\ and  Transferred it to my laptop and put it in the same 
directory as my test program and now it's running fine.  

>You may benefit from such tool as a dependency walker 
>(https://en.wikipedia.org/wiki/Dependency_Walker).

Thanks for the advice, I will check it out.

Jim


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Monday, June 05, 2017 6:19 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

How did you build/get freetype.dll? If it was built using Visual Studio, 
freetype.dll might have been linked against a newer C++ runtime such as 
msvcr71.dll that is not shipped with windows by default. You clearly need to 
deploy C++ runtime libs as well with your product.
You may benefit from such tool as a dependency walker 
(https://en.wikipedia.org/wiki/Dependency_Walker).
On linux you can just use ldd.

Hope this helps,

Stefan

On 06/05/2017 05:00 PM, James Richters wrote:
>> As for font support under Windows. Yes you can use GDI for font rendering, 
>> but I highly recommend using freetype.dll even under Windows.
>> It has more features than GDI font support and the quality is better too.
>
> Is it the fonts causing the dependency then?  I have freetype.dll included in 
> the directory with my programs, do I need to include other files / dlls if I 
> want them to run without installing anything?
>
> the programs I am getting the dependency  issue with are based on and 
> including Graeme's original sample program Agg2DColsole.dpr ,  they use:
> Ptcgraph,
> Ptccrt,
> Sysutils,
> Fpimage,
> Fpwritepng,
> Agg_2d,
> Agg_Basics
>
>
> James
>
>
> -Original Message-
> From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On 
> Behalf Of Graeme Geldenhuys
> Sent: Monday, June 05, 2017 2:25 PM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph
>
> On 2017-06-05 03:12, Stefan V. Pantazi wrote:
>> In my experience, the one dependency that AggPas has potential to 
>> fail may be related to the freetype library. If you plan to run your 
>> app on windows only, then you can turn freetype off and AggPas will 
>> happily use windows font libraries. Search for the AGG2D_USE_FREETYPE 
>> define and comment it out.
>
> Correct, though even font support is optional in AggPas. So if you don't 
> render text via AggPas, it has zero dependency - everything is done in pure 
> Object Pascal code.
>
> As for font support under Windows. Yes you can use GDI for font rendering, 
> but I highly recommend using freetype.dll even under Windows.
> It has more features than GDI font support and the quality is better too.
>
> Regards,
>Graeme
>
> --
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
> http://fpgui.sourceforge.net/
>
> My public PGP key:  http://tinyurl.com/graeme-pgp 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

--
___
Stefan V. Pantazi, MD, PhD
Professor, Health Informatics
School of Health & Life Sciences and Community Services Conestoga College 
Institute of Technology and Advanced Learning
299 Doon Valley Drive
Kitchener, ON, Canada, N2G 4M4  
office: 1C23
phone:  (519) 748-5220 ext. 3950
email:  svpant...@gmail.com
web:https://sites.google.com/site/stefanvpantazi/   
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-05 Thread Stefan V. Pantazi
How did you build/get freetype.dll? If it was built using Visual Studio, 
freetype.dll might have been linked against a newer C++ runtime such as 
msvcr71.dll that is not shipped with windows by default. You clearly 
need to deploy C++ runtime libs as well with your product.
You may benefit from such tool as a dependency walker 
(https://en.wikipedia.org/wiki/Dependency_Walker).

On linux you can just use ldd.

Hope this helps,

Stefan

On 06/05/2017 05:00 PM, James Richters wrote:

As for font support under Windows. Yes you can use GDI for font rendering, but 
I highly recommend using freetype.dll even under Windows.
It has more features than GDI font support and the quality is better too.


Is it the fonts causing the dependency then?  I have freetype.dll included in 
the directory with my programs, do I need to include other files / dlls if I 
want them to run without installing anything?

the programs I am getting the dependency  issue with are based on and including 
Graeme's original sample program Agg2DColsole.dpr ,  they use:
Ptcgraph,
Ptccrt,
Sysutils,
Fpimage,
Fpwritepng,
Agg_2d,
Agg_Basics


James


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Monday, June 05, 2017 2:25 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-05 03:12, Stefan V. Pantazi wrote:

In my experience, the one dependency that AggPas has potential to fail
may be related to the freetype library. If you plan to run your app on
windows only, then you can turn freetype off and AggPas will happily
use windows font libraries. Search for the AGG2D_USE_FREETYPE define
and comment it out.


Correct, though even font support is optional in AggPas. So if you don't render 
text via AggPas, it has zero dependency - everything is done in pure Object 
Pascal code.

As for font support under Windows. Yes you can use GDI for font rendering, but 
I highly recommend using freetype.dll even under Windows.
It has more features than GDI font support and the quality is better too.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



--
___
Stefan V. Pantazi, MD, PhD
Professor, Health Informatics
School of Health & Life Sciences and Community Services
Conestoga College Institute of Technology and Advanced Learning
299 Doon Valley Drive
Kitchener, ON, Canada, N2G 4M4  
office: 1C23
phone:  (519) 748-5220 ext. 3950
email:  svpant...@gmail.com
web:https://sites.google.com/site/stefanvpantazi/   
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-05 Thread James Richters
>As for font support under Windows. Yes you can use GDI for font rendering, but 
>I highly recommend using freetype.dll even under Windows. 
>It has more features than GDI font support and the quality is better too.

Is it the fonts causing the dependency then?  I have freetype.dll included in 
the directory with my programs, do I need to include other files / dlls if I 
want them to run without installing anything?

the programs I am getting the dependency  issue with are based on and including 
Graeme's original sample program Agg2DColsole.dpr ,  they use:
Ptcgraph,
Ptccrt,
Sysutils,
Fpimage,
Fpwritepng,
Agg_2d,
Agg_Basics


James


-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Monday, June 05, 2017 2:25 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-06-05 03:12, Stefan V. Pantazi wrote:
> In my experience, the one dependency that AggPas has potential to fail 
> may be related to the freetype library. If you plan to run your app on 
> windows only, then you can turn freetype off and AggPas will happily 
> use windows font libraries. Search for the AGG2D_USE_FREETYPE define 
> and comment it out.

Correct, though even font support is optional in AggPas. So if you don't render 
text via AggPas, it has zero dependency - everything is done in pure Object 
Pascal code.

As for font support under Windows. Yes you can use GDI for font rendering, but 
I highly recommend using freetype.dll even under Windows. 
It has more features than GDI font support and the quality is better too.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-05 Thread Graeme Geldenhuys

On 2017-06-05 03:12, Stefan V. Pantazi wrote:

In my experience, the one dependency that AggPas has potential to fail
may be related to the freetype library. If you plan to run your app on
windows only, then you can turn freetype off and AggPas will happily use
windows font libraries. Search for the AGG2D_USE_FREETYPE define and
comment it out.


Correct, though even font support is optional in AggPas. So if you don't 
render text via AggPas, it has zero dependency - everything is done in 
pure Object Pascal code.


As for font support under Windows. Yes you can use GDI for font 
rendering, but I highly recommend using freetype.dll even under Windows. 
It has more features than GDI font support and the quality is better too.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-05 Thread Graeme Geldenhuys

On 2017-06-04 23:30, James Richters wrote:

to run them I get a "system error: The Program can't start because
MSVCR71.dll is missing from your computer.


AggPas definitely doesn't require such a library, so your program must 
be using something else that pulls that dependency in.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-04 Thread Stefan V. Pantazi
I've tested the example on 64 bit linux as a native application as well 
cross compiled for a x86_64 windows target. Worked fine in both Wine and 
on a Win64 machine.


In my experience, the one dependency that AggPas has potential to fail 
may be related to the freetype library. If you plan to run your app on 
windows only, then you can turn freetype off and AggPas will happily use 
windows font libraries. Search for the AGG2D_USE_FREETYPE define and 
comment it out.


Hope this helps,

Stefan

On 06/04/2017 06:30 PM, James Richters wrote:

Thanks for figuring out how to make this work, I would have never figured it
out with the documentation I was able to find.

I'm out of town this week so I tried to download the sample program to my
laptop and discovered another issue.  While I can normally just compile my
programs on my laptop and run them,  I have noticed that I can't do this
with programs with aggpas in them. They compile successfully but when I try
to run them I get a "system error: The Program can't start because
MSVCR71.dll is missing from your computer.  Try reinstalling the program to
fix this problem"  I suspect I get this because I have never actually
installed free Pascal or something that I happened to install on my
development pc on my laptop, I have always run freepascal it from a backup
made from my development machine.   I have not tried installing freepascal
on my lap top yet because I would like to figure out what I will need to do
on my target installations where freepascal will not be installed.

Any ideas on what causes this error and advice on how to install what is
needed on client (non-development) systems?

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf
Of Stefan V. Pantazi
Sent: Saturday, June 03, 2017 12:45 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

I seem to have some problems with logging on the bug tracker. I've used it
in the recent past a couple of time but I am unable to log on for some
reason. I will try later to create a new account and submit a fpc doc bug
report.

At any rate, I attached the updated example based on Nikolay's recent post
which had the correct information. There was a third "reserved"
parameter that had to be added to the bitmap buffer structure. Without it,
the output was slightly clipped to the right. Also, for the example to work,
the agg object constructor must be modified as well, I included all the info
in the example header. I think the example program
(aggpas_ptcgraph_output.pas) fits well together with the other demos in
fpGUI and PtcPas/ptcgraph packages, so adding it to the packages would help,
regardless whether graph.PutImage documentation is updated.

Stefan

On 06/03/2017 06:52 AM, Graeme Geldenhuys wrote:

On 2017-06-03 01:56, Stefan V. Pantazi wrote:

http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of
the region, and the bit image that will be put onto the screen."
[...]



Could you file a FPC Documentation bug report and ask that this
information be added. As you found out (very difficultly), this is vital
information.


Regards,
  Graeme



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



--
___
Stefan V. Pantazi, MD, PhD
Professor, Health Informatics
School of Health & Life Sciences and Community Services
Conestoga College Institute of Technology and Advanced Learning
299 Doon Valley Drive
Kitchener, ON, Canada, N2G 4M4  
office: 1C23
phone:  (519) 748-5220 ext. 3950
email:  svpant...@gmail.com
web:https://sites.google.com/site/stefanvpantazi/   
___
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-04 Thread James Richters
Thanks for figuring out how to make this work, I would have never figured it
out with the documentation I was able to find.

I'm out of town this week so I tried to download the sample program to my
laptop and discovered another issue.  While I can normally just compile my
programs on my laptop and run them,  I have noticed that I can't do this
with programs with aggpas in them. They compile successfully but when I try
to run them I get a "system error: The Program can't start because
MSVCR71.dll is missing from your computer.  Try reinstalling the program to
fix this problem"  I suspect I get this because I have never actually
installed free Pascal or something that I happened to install on my
development pc on my laptop, I have always run freepascal it from a backup
made from my development machine.   I have not tried installing freepascal
on my lap top yet because I would like to figure out what I will need to do
on my target installations where freepascal will not be installed.  

Any ideas on what causes this error and advice on how to install what is
needed on client (non-development) systems?

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf
Of Stefan V. Pantazi
Sent: Saturday, June 03, 2017 12:45 PM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

I seem to have some problems with logging on the bug tracker. I've used it
in the recent past a couple of time but I am unable to log on for some
reason. I will try later to create a new account and submit a fpc doc bug
report.

At any rate, I attached the updated example based on Nikolay's recent post
which had the correct information. There was a third "reserved" 
parameter that had to be added to the bitmap buffer structure. Without it,
the output was slightly clipped to the right. Also, for the example to work,
the agg object constructor must be modified as well, I included all the info
in the example header. I think the example program
(aggpas_ptcgraph_output.pas) fits well together with the other demos in
fpGUI and PtcPas/ptcgraph packages, so adding it to the packages would help,
regardless whether graph.PutImage documentation is updated.

Stefan

On 06/03/2017 06:52 AM, Graeme Geldenhuys wrote:
> On 2017-06-03 01:56, Stefan V. Pantazi wrote:
>> http://pascal.net.ru/PutImage+(en)
>> [...]
>> "BitMap is an untyped parameter that contains the height and width of
>> the region, and the bit image that will be put onto the screen."
>> [...]
>
>
> Could you file a FPC Documentation bug report and ask that this
> information be added. As you found out (very difficultly), this is vital
> information.
>
>
> Regards,
>   Graeme
>

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Stefan V. Pantazi
The easiest workaround I could figure was to add a parameter to the 
Agg2D object constructor. That should, in theory, allow the use of any 
pixel format available in AggPas.


The ptcpas/ptcgraph units I used are the ones that came with fpc 3.0.1, 
there was no need to download anything. They worked fine, except for one 
48 bytes memory leak reported by heaptrc and that I left unfixed.


Stefan

On 06/03/2017 03:37 PM, Graeme Geldenhuys wrote:

On 2017-06-03 17:45, Stefan V. Pantazi wrote:

Also, for the example
to work, the agg object constructor must be modified as well, I included
all the info in the example header.


I noted the remarks on the image buffer format being hard-coded for the
Agg_2D unit. I'll make a plan for improving that, using some Factory
(design) Pattern to register the pixel buffer format of interest.



I think the example program
(aggpas_ptcgraph_output.pas) fits well together with the other demos in
fpGUI and PtcPas/ptcgraph packages, so adding it to the packages would
help, regardless whether graph.PutImage documentation is updated.


Thanks. I'll download the ptcgraph unit and give it a test. I'll all the
demo to fpGUI's AggPas demos too. It will be a good addition.

Regards,
  Graeme


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Graeme Geldenhuys

On 2017-06-03 17:45, Stefan V. Pantazi wrote:

Also, for the example
to work, the agg object constructor must be modified as well, I included
all the info in the example header.


I noted the remarks on the image buffer format being hard-coded for the 
Agg_2D unit. I'll make a plan for improving that, using some Factory 
(design) Pattern to register the pixel buffer format of interest.




I think the example program
(aggpas_ptcgraph_output.pas) fits well together with the other demos in
fpGUI and PtcPas/ptcgraph packages, so adding it to the packages would
help, regardless whether graph.PutImage documentation is updated.


Thanks. I'll download the ptcgraph unit and give it a test. I'll all the 
demo to fpGUI's AggPas demos too. It will be a good addition.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Stefan V. Pantazi
I seem to have some problems with logging on the bug tracker. I've used 
it in the recent past a couple of time but I am unable to log on for 
some reason. I will try later to create a new account and submit a fpc 
doc bug report.


At any rate, I attached the updated example based on Nikolay's recent 
post which had the correct information. There was a third "reserved" 
parameter that had to be added to the bitmap buffer structure. Without 
it, the output was slightly clipped to the right. Also, for the example 
to work, the agg object constructor must be modified as well, I included 
all the info in the example header. I think the example program 
(aggpas_ptcgraph_output.pas) fits well together with the other demos in 
fpGUI and PtcPas/ptcgraph packages, so adding it to the packages would 
help, regardless whether graph.PutImage documentation is updated.


Stefan

On 06/03/2017 06:52 AM, Graeme Geldenhuys wrote:

On 2017-06-03 01:56, Stefan V. Pantazi wrote:

http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of
the region, and the bit image that will be put onto the screen."
[...]



Could you file a FPC Documentation bug report and ask that this
information be added. As you found out (very difficultly), this is vital
information.


Regards,
  Graeme

(*
  This is a minimalistic console application demo derived from the Agg2DConsole.dpr at

  https://github.com/graemeg/fpGUI/tree/develop/src/corelib/render/software/agg-demos

  It uses the Agg2D object in AggPas, which has a much friendlier API, to do all the drawing.

  The drawing buffer is then displayed in a window using ptcgraph and 16 bit RGB565 color format.

  Uses a GraphBitmapBuffer record type that includes the width and height of the image as well as a reserved parameter
  per the info in this post: http://lists.freepascal.org/pipermail/fpc-pascal/2017-June/051524.html

  [...]
  "The structure, used by putimage is as follows:
  3 longints (12 bytes):
  - image width
  - image height
  - reserved
  followed by width*height 16-bit words.
  [...]

  Agg2D object constructor requires a modification to use pixel formats other than rgba32 (e.g., 16 bit RGB565 color format) as follows:
[...]
  public
constructor Construct(pixfmt:define_pixfmt);
destructor  Destruct;
[...]
  { CONSTRUCT }
  constructor Agg2D.Construct(pixfmt:define_pixfmt);
  begin
   	m_rbuf.Construct;

  	pixfmt(m_pixFormat ,@m_rbuf);
  	pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order );
   	pixfmt(m_pixFormatPre ,@m_rbuf);
   	pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order);
[...]

ADDITIONAL NOTES:
- although rendering appears to work with pixel formats other than rgba32, custom blending may need further testing.
- there may other implementations of graph units and video modes requiring a different bitmap structure than the one
used below.
- example is tested with fpc 3.0.1 and Agg2D - Version 1.0 Release Milano 3 (AggPas 2.4 RM3)
*)

program aggpas_ptcgraph_output;

{$mode objfpc}{$H+}

uses
  ptcgraph,
  ptccrt,
	agg_pixfmt_rgb_packed, //for pixfmt_rgb565
  agg_2D;

const
  IMAGE_WIDTH = 800;
  IMAGE_HEIGHT = 600;
  RGB_WIDTH =2; //16bit RGB565 format
  LINE_COUNT = 30;

type

TGraphBitmapBuffer=packed record
  width,
  height,
  reserved:	longint;//per info in http://lists.freepascal.org/pipermail/fpc-pascal/2017-June/051524.html
  data: 	array[0..RGB_WIDTH*IMAGE_WIDTH*IMAGE_HEIGHT-1] of byte;
end;

var
  gd,gm : smallint;
  graph_buffer: TGraphBitmapBuffer;

procedure DrawStuff(agg: Agg2D_ptr);
var
  i: Integer;
  x, y, px, py, d: Double;
  c1, c2: Color;
begin
  // draw a full screen graph with grid
  agg^.clearAll(0, 0, 0);
  agg^.lineColor(0, 0, 0, 255);
  agg^.lineWidth(3);
  agg^.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
  agg^.lineWidth(1);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
//  agg^.font(fontfile, 16);
  d := IMAGE_WIDTH / LINE_COUNT;
  agg^.lineColor(0, 0, 0, 100);
  agg^.lineWidth(1);
  for i := 1 to LINE_COUNT - 1 do
  begin
x := i * d;
agg^.line(x, 0, x, IMAGE_HEIGHT);
  end;
  for i := 1 to trunc(IMAGE_HEIGHT / d) do
  begin
y := i * d;
agg^.line(0, y, IMAGE_WIDTH, y);
  end;
  x := 0;
  y := IMAGE_HEIGHT / 2;
  px := x;
  py := y;
  agg^.lineColor(255, 0, 0, 200);
  agg^.fillColor(0, 0, 0, 200);
  agg^.lineWidth(1);
  for i := 0 to LINE_COUNT - 1 do
  begin
x := x + d;
y := y + Random(Round(IMAGE_HEIGHT / 3)) - IMAGE_HEIGHT / 6;
if y < 0 then
  y := IMAGE_HEIGHT / 6;
if y >= IMAGE_HEIGHT then
  y := IMAGE_HEIGHT - IMAGE_HEIGHT / 6;
agg^.line(px, py, x, y);
//agg^.text(x, y, char_ptr(IntToStr(i) + ' point'));
px := x;
py := y;
  end;

  // Star shape
  agg^.LineCap(CapRound);
  agg^.LineWidth(5);
  agg^.LineColor($32 ,$cd ,$32 );
  c1.Construct(0, 0 , 255, 200);
  c2.Construct(0, 0, 255, 50);
  agg^.FillLinearGradient(100, 100, 

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Nikolay Nikolov



On 06/03/2017 01:52 PM, Graeme Geldenhuys wrote:

On 2017-06-03 01:56, Stefan V. Pantazi wrote:

http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of
the region, and the bit image that will be put onto the screen."
[...]



Could you file a FPC Documentation bug report and ask that this 
information be added. As you found out (very difficultly), this is 
vital information.
Even though this is the default implementation (and ptcgraph uses it), 
there may be different graph unit implementations that use a different 
format in some or all of their video modes. Of course, this should also 
be mentioned in the documentation.


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Graeme Geldenhuys

On 2017-06-03 01:56, Stefan V. Pantazi wrote:

http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of
the region, and the bit image that will be put onto the screen."
[...]



Could you file a FPC Documentation bug report and ask that this 
information be added. As you found out (very difficultly), this is vital 
information.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-03 Thread Stefan V. Pantazi
An interesting challenge. It works now. I updated your test program, 
made it as minimal as possible (see attached). The key to solving the 
problem was the info available here:


http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of 
the region, and the bit image that will be put onto the screen."

[...]

Enjoy,

Stefan


On 06/02/2017 07:40 AM, James Richters wrote:

Thanks for the help. I was able to make a little progress.


There is another agg unit agg_pixfmt_rgb_packed that seem to have the
565 format that you need. Add it to the uses list and try to replace the
pixfmt_rgba32 calls with pixfmt_rgb565. That will make agg use that format.
The pixfmt_custom_blend_rgba calls may need further hacking too to make things 
work, however, Agg2D should use a 16 bit format if you use
pixfmt_rgb565 callse instead of pixfmt_rgba32. You should also set RGBA_Width 
=2; in your program to reflect the change.


I did as you suggest here and changed my buffer to be an array of words, and I 
am able to get a representation of the image to screen by reading elements of 
the array and using putpixel() to put them on the screen,  however the colors 
are all wrong.  I am wondering if this m_pixformat variable that shows up 
everywhere needs to be set also?   The pixfmt_custom_blend_rgba calls may also 
be the problem with the colors.  There are no corresponding custom blend 
procedures in agg_pixfmt_rgb_packed.


Anyway, this will probably still not make
ptcgraph.putimage(0,0,buf[0],0);

No this still does not work, I am able to use a nested loop and putpixel() but 
that is very slow.  I still think something is missing with putimage because I 
don't see how it knows the shape of the image, maybe I need to actually do a 
getimage() at some point to set the shape of before putimage will work.. I'll 
do some experiments with it.

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Thursday, June 01, 2017 9:47 AM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

Have a look at the agg_2D unit. The agg_2D uses ..
  agg_pixfmt ,
  agg_pixfmt_rgba ,
..

Therefore, the rgba format is pretty much baked in. That is to say that the 
constructor of the main object Agg2D uses the pixfmt_rgba32 to set the pixel 
format.

...
{ CONSTRUCT }
constructor Agg2D.Construct;
begin
  m_rbuf.Construct;

  pixfmt_rgba32   (m_pixFormat ,@m_rbuf );
  pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf ,@comp_op_adaptor_rgba 
,rgba_order );
  pixfmt_rgba32   (m_pixFormatPre ,@m_rbuf );
  pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf ,@comp_op_adaptor_rgba 
,rgba_order ); ...

There is another agg unit agg_pixfmt_rgb_packed that seem to have the
565 format that you need. Add it to the uses list and try to replace the
pixfmt_rgba32 calls with pixfmt_rgb565. That will make agg use that format.

The pixfmt_custom_blend_rgba calls may need further hacking too to make things 
work, however, Agg2D should use a 16 bit format if you use
pixfmt_rgb565 callse instead of pixfmt_rgba32. You should also set RGBA_Width 
=2; in your program to reflect the change.

Anyway, this will probably still not make

ptcgraph.putimage(0,0,buf[0],0);
work, but that may be a ptcgraph problem.


Hope this helps,

Stefan

On 05/31/2017 02:57 PM, James Richters wrote:

And AggPas already has support for that pixel format


How do I define that as the format I want?  I've been looking all through the 
example and do not see how this is defined.  I've attached a test program, it's 
basically Graeme's sample but going to screen instead of a file.  I just don't 
see where the pixel format is defined.  I have it kind of working in a funny 
way by just forcing the existing pixels to conform to the required format.

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On
Behalf Of Graeme Geldenhuys
Sent: Wednesday, May 31, 2017 1:17 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-31 18:03, Reimar Grabowski wrote:

I'm not sure what that's called

RGB565, maybe?


And AggPas already has support for that pixel format.

Regards,
   Graeme

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.fre

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-02 Thread Stefan V. Pantazi
I literally just sent a reply with the solution. I had to guess the 
width and height were longints. Your message confirmed it. I attached an 
updated version of the test program, the old one had a few typos.


Thank you for your work on the ptcpas, I found it very useful for my 
projects.


On 06/02/2017 08:39 PM, Nikolay Nikolov wrote:



On 05/31/2017 02:51 PM, James Richters wrote:

I was doing some tests with Putpixel and that seems to be a word in
the format of RGBA with 4 bits each.I would think putimage would
use the same format, but I haven't tested that yet.

I'm still a bit confused by putimage, since it only has an X and Y
startpoint, how do you define the height and width of the bitmap?
Getimage() specifies a rectangle, and imagesize() figures out how much
memory you need, but I just don't what defines the size and shape of
the image to putimage.

The structure, used by putimage is as follows:

3 longints (12 bytes):
- image width
- image height
- reserved

followed by width*height 16-bit words. If you're a using a 16-bit color
mode (that's the highest supported - it's a limitation of the graph unit
include files, which ptcgraph reuses from the fpc sources), the color
format is rgb565.

Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
{
  This is a console application demo. It uses the Agg2D object,
  which has a much friendlier API, to do all the drawing.
  The drawing buffer is then displayed in a window using ptcgraph and 16 bit 
RGB565 color format.

  Requires modification of Agg2D object constructor to use the 16 bit RGB565 
color format.
  Uses a GraphBitmapBuffer type that includes contains the width and height of 
the image per the info at this URL:

http://pascal.net.ru/PutImage+(en)
[...]
"BitMap is an untyped parameter that contains the height and width of the 
region, and the bit image that will be put onto the screen."
[...]
}

program console_aggpas_2;

{$mode objfpc}{$H+}

uses
  ptcgraph,
  ptccrt,
  agg_2D,
  agg_basics;

const
  IMAGE_WIDTH = 800;
  IMAGE_HEIGHT = 600;
  RGBA_WIDTH =2; //16bit 565 format
  LINE_COUNT = 30;
  {$IFDEF Unix}
  FontFile = '../../arial.ttf';
  {$ENDIF}
  {$IFDEF Windows}
  FontFile = 'Arial';
  {$ENDIF}

type

TGraphBitmapBuffer=packed record
  width,
  height:   longint;
  data: array[0..2*IMAGE_WIDTH*IMAGE_HEIGHT-1] of byte;
end;

var
  gd,gm : smallint;
  graph_buffer: TGraphBitmapBuffer;

procedure DrawStuff(agg: Agg2D_ptr);
var
  i: Integer;
  x, y, px, py, d: Double;
  c1, c2: Color;
begin
  // draw a full screen graph with grid
  agg^.clearAll(0, 0, 0);
  agg^.lineColor(0, 0, 0, 255);
  agg^.lineWidth(3);
  agg^.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
  agg^.lineWidth(1);
  agg^.lineColor(0, 155, 0, 255);
  agg^.rectangle(10, 10, 50, 50);
//  agg^.font(fontfile, 16);
  d := IMAGE_WIDTH / LINE_COUNT;
  agg^.lineColor(0, 0, 0, 100);
  agg^.lineWidth(1);
  for i := 1 to LINE_COUNT - 1 do
  begin
x := i * d;
agg^.line(x, 0, x, IMAGE_HEIGHT);
  end;
  for i := 1 to trunc(IMAGE_HEIGHT / d) do
  begin
y := i * d;
agg^.line(0, y, IMAGE_WIDTH, y);
  end;
  x := 0;
  y := IMAGE_HEIGHT / 2;
  px := x;
  py := y;
  agg^.lineColor(255, 0, 0, 200);
  agg^.fillColor(0, 0, 0, 200);
  agg^.lineWidth(1);
  for i := 0 to LINE_COUNT - 1 do
  begin
x := x + d;
y := y + Random(Round(IMAGE_HEIGHT / 3)) - IMAGE_HEIGHT / 6;
if y < 0 then
  y := IMAGE_HEIGHT / 6;
if y >= IMAGE_HEIGHT then
  y := IMAGE_HEIGHT - IMAGE_HEIGHT / 6;
agg^.line(px, py, x, y);
//agg^.text(x, y, char_ptr(IntToStr(i) + ' point'));
px := x;
py := y;
  end;

  // Star shape
  agg^.LineCap(CapRound);
  agg^.LineWidth(5);
  agg^.LineColor($32 ,$cd ,$32 );
  c1.Construct(0, 0 , 255, 200);
  c2.Construct(0, 0, 255, 50);
  agg^.FillLinearGradient(100, 100, 150, 150, c1, c2);
  agg^.Star(100 ,150 ,30 ,70 ,55 ,5 );

  // Draw Arc from 45 degrees to 270 degrees
  agg^.LineColor($4C, $6C, $9C);
  agg^.LineWidth(5 );
  agg^.Arc(300 ,320 ,80 ,50 ,Deg2Rad(45 ) ,Deg2Rad(270 ) );
end;


procedure DrawAndDisplay;
var
  agg: Agg2D_ptr;
begin
//agg draw
  New(agg, Construct);
  agg^.attach(@graph_buffer.data, IMAGE_WIDTH, IMAGE_HEIGHT, -(IMAGE_WIDTH * 
RGBA_WIDTH));
  DrawStuff(agg);
  Dispose(agg, Destruct); // not necessary to keep it after rendering is 
finished

//display on ptc surface
graph_buffer.width:=IMAGE_WIDTH;
graph_buffer.height:=IMAGE_HEIGHT;
  ptcgraph.PutImage(0,0,graph_buffer,NormalPut);
  ptcgraph.Rectangle(10,10,100,100);
  ptcgraph.PieSlice(100,100,0,25,30);
  ptcgraph.OutTextXY(80,80,'It works!');
end;


begin
  gd:=d16Bit;
  gm:=m800x600;
  //Windowtitle:='ptcgraph';
  ptcgraph.Initgraph(gd,gm,'');
  Randomize;
  DrawAndDisplay;
  ReadKey;
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-02 Thread Nikolay Nikolov



On 05/31/2017 02:51 PM, James Richters wrote:

I was doing some tests with Putpixel and that seems to be a word in the format 
of RGBA with 4 bits each.I would think putimage would use the same format, 
but I haven't tested that yet.

I'm still a bit confused by putimage, since it only has an X and Y startpoint, 
how do you define the height and width of the bitmap? Getimage() specifies a 
rectangle, and imagesize() figures out how much memory you need, but I just 
don't what defines the size and shape of the image to putimage.

The structure, used by putimage is as follows:

3 longints (12 bytes):
- image width
- image height
- reserved

followed by width*height 16-bit words. If you're a using a 16-bit color 
mode (that's the highest supported - it's a limitation of the graph unit 
include files, which ptcgraph reuses from the fpc sources), the color 
format is rgb565.


Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-02 Thread James Richters
Thanks for the help. I was able to make a little progress.

>There is another agg unit agg_pixfmt_rgb_packed that seem to have the
>565 format that you need. Add it to the uses list and try to replace the
>pixfmt_rgba32 calls with pixfmt_rgb565. That will make agg use that format.
>The pixfmt_custom_blend_rgba calls may need further hacking too to make things 
>work, however, Agg2D should use a 16 bit format if you use
>pixfmt_rgb565 callse instead of pixfmt_rgba32. You should also set RGBA_Width 
>=2; in your program to reflect the change.

I did as you suggest here and changed my buffer to be an array of words, and I 
am able to get a representation of the image to screen by reading elements of 
the array and using putpixel() to put them on the screen,  however the colors 
are all wrong.  I am wondering if this m_pixformat variable that shows up 
everywhere needs to be set also?   The pixfmt_custom_blend_rgba calls may also 
be the problem with the colors.  There are no corresponding custom blend 
procedures in agg_pixfmt_rgb_packed.

>Anyway, this will probably still not make
>ptcgraph.putimage(0,0,buf[0],0);
No this still does not work, I am able to use a nested loop and putpixel() but 
that is very slow.  I still think something is missing with putimage because I 
don't see how it knows the shape of the image, maybe I need to actually do a 
getimage() at some point to set the shape of before putimage will work.. I'll 
do some experiments with it.  

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Stefan V. Pantazi
Sent: Thursday, June 01, 2017 9:47 AM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

Have a look at the agg_2D unit. The agg_2D uses ..
  agg_pixfmt ,
  agg_pixfmt_rgba ,
..

Therefore, the rgba format is pretty much baked in. That is to say that the 
constructor of the main object Agg2D uses the pixfmt_rgba32 to set the pixel 
format.

...
{ CONSTRUCT }
constructor Agg2D.Construct;
begin
  m_rbuf.Construct;

  pixfmt_rgba32   (m_pixFormat ,@m_rbuf );
  pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf ,@comp_op_adaptor_rgba 
,rgba_order );
  pixfmt_rgba32   (m_pixFormatPre ,@m_rbuf );
  pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf ,@comp_op_adaptor_rgba 
,rgba_order ); ...

There is another agg unit agg_pixfmt_rgb_packed that seem to have the
565 format that you need. Add it to the uses list and try to replace the
pixfmt_rgba32 calls with pixfmt_rgb565. That will make agg use that format.

The pixfmt_custom_blend_rgba calls may need further hacking too to make things 
work, however, Agg2D should use a 16 bit format if you use
pixfmt_rgb565 callse instead of pixfmt_rgba32. You should also set RGBA_Width 
=2; in your program to reflect the change.

Anyway, this will probably still not make

ptcgraph.putimage(0,0,buf[0],0);
work, but that may be a ptcgraph problem.


Hope this helps,

Stefan

On 05/31/2017 02:57 PM, James Richters wrote:
>> And AggPas already has support for that pixel format
>
> How do I define that as the format I want?  I've been looking all through the 
> example and do not see how this is defined.  I've attached a test program, 
> it's basically Graeme's sample but going to screen instead of a file.  I just 
> don't see where the pixel format is defined.  I have it kind of working in a 
> funny way by just forcing the existing pixels to conform to the required 
> format.
>
> -Original Message-
> From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On 
> Behalf Of Graeme Geldenhuys
> Sent: Wednesday, May 31, 2017 1:17 PM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph
>
> On 2017-05-31 18:03, Reimar Grabowski wrote:
>>> I'm not sure what that's called
>> RGB565, maybe?
>
> And AggPas already has support for that pixel format.
>
> Regards,
>Graeme
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-01 Thread Stefan V. Pantazi

Have a look at the agg_2D unit. The agg_2D uses
..
 agg_pixfmt ,
 agg_pixfmt_rgba ,
..

Therefore, the rgba format is pretty much baked in. That is to say that 
the constructor of the main object Agg2D uses the pixfmt_rgba32 to set 
the pixel format.


...
{ CONSTRUCT }
constructor Agg2D.Construct;
begin
 m_rbuf.Construct;

 pixfmt_rgba32   (m_pixFormat ,@m_rbuf );
 pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf 
,@comp_op_adaptor_rgba ,rgba_order );

 pixfmt_rgba32   (m_pixFormatPre ,@m_rbuf );
 pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf 
,@comp_op_adaptor_rgba ,rgba_order );

...

There is another agg unit agg_pixfmt_rgb_packed that seem to have the 
565 format that you need. Add it to the uses list and try to replace the 
pixfmt_rgba32 calls with pixfmt_rgb565. That will make agg use that format.


The pixfmt_custom_blend_rgba calls may need further hacking too to make 
things work, however, Agg2D should use a 16 bit format if you use 
pixfmt_rgb565 callse instead of pixfmt_rgba32. You should also set 
RGBA_Width =2; in your program to reflect the change.


Anyway, this will probably still not make

ptcgraph.putimage(0,0,buf[0],0);

work, but that may be a ptcgraph problem.


Hope this helps,

Stefan

On 05/31/2017 02:57 PM, James Richters wrote:

And AggPas already has support for that pixel format


How do I define that as the format I want?  I've been looking all through the 
example and do not see how this is defined.  I've attached a test program, it's 
basically Graeme's sample but going to screen instead of a file.  I just don't 
see where the pixel format is defined.  I have it kind of working in a funny 
way by just forcing the existing pixels to conform to the required format.

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Wednesday, May 31, 2017 1:17 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-31 18:03, Reimar Grabowski wrote:

I'm not sure what that's called

RGB565, maybe?


And AggPas already has support for that pixel format.

Regards,
   Graeme

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-31 Thread James Richters
>And AggPas already has support for that pixel format

How do I define that as the format I want?  I've been looking all through the 
example and do not see how this is defined.  I've attached a test program, it's 
basically Graeme's sample but going to screen instead of a file.  I just don't 
see where the pixel format is defined.  I have it kind of working in a funny 
way by just forcing the existing pixels to conform to the required format. 

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Wednesday, May 31, 2017 1:17 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-31 18:03, Reimar Grabowski wrote:
>> I'm not sure what that's called
> RGB565, maybe?

And AggPas already has support for that pixel format.

Regards,
   Graeme

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Graphtest2.pas
Description: Binary data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-31 Thread Graeme Geldenhuys

On 2017-05-31 18:03, Reimar Grabowski wrote:

I'm not sure what that's called

RGB565, maybe?


And AggPas already has support for that pixel format.

Regards,
  Graeme

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-31 Thread Reimar Grabowski
On Wed, 31 May 2017 10:47:40 -0400
"James Richters"  wrote:

> It's a word with:
> 5bits red, 6bits green, and 5bits blue like this:
> 
> RGGB
> 
> I'm not sure what that's called
RGB565, maybe?

R.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-31 Thread James Richters
>seems to be a word in the format of RGBA with 4 bits each

Well, it seemed to be RGBA, but it's not...  

It's a word with:
5bits red, 6bits green, and 5bits blue like this:

RGGB

I'm not sure what that's called or how to set up aggpas to use that, but that's 
what it seems to be if ptcgraph is put in a 16bit color mode.  It doesn't seem 
to be able to go any higher than that, but that's fine for my purposes.

James




-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
James Richters
Sent: Wednesday, May 31, 2017 7:52 AM
To: 'FPC-Pascal users discussions' <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

I was doing some tests with Putpixel and that seems to be a word in the format 
of RGBA with 4 bits each.I would think putimage would use the same format, 
but I haven't tested that yet.

I'm still a bit confused by putimage, since it only has an X and Y startpoint, 
how do you define the height and width of the bitmap? Getimage() specifies a 
rectangle, and imagesize() figures out how much memory you need, but I just 
don't what defines the size and shape of the image to putimage.

I managed to get the test out of the buffer and onto the screen with :

  function getBufItemAsByte(aDelta: Word): Byte;
  var
actualY: Integer;
thing:Byte;
  begin
actualY := ImageHeight - y - 1;
thing :=
  byte(buf[x * RGBA_Width + actualY * ImageWidth * RGBA_Width + aDelta]);
result:=thing shr 4;  //colors channels are reduced to 4 bits each, they 
are not correct
  end;

for x := 0 to ImageWidth - 1 do
   for y := 0 to ImageHeight - 1 do
   begin
  pixelcolor:=(getBufItemAsbyte(2) shl 12)+(getBufItemAsbyte(1) shl 8) 
+(getBufItemAsbyte(0) shl 4)+getBufItemAsbyte(3);
  putpixel(x,y,pixelcolor);
  end;


James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Tuesday, May 30, 2017 8:19 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-30 22:37, James Richters wrote:

> Putimage() takes
> Initial X position
> Initial Y position
> Pointer to beginning of memory bitmap

In that case the AggPas code should be even faster, because PutImage() only 
want a pointer to the bitmap data - thus no need to go through the slow FPImage 
code to generate a PNG or BMP image. The pixel-by-pixel conversions for FPImage 
is very slow.

>Size := ImageSize(10, 20, 30, 40);
>GetMem(Q, Size);   { Allocate memory on heap }

So you can do pretty much the same with AggPas then. Allocate the memory you 
need, and attach that as the rendering buffer or AggPas. As I mentioned before, 
AggPas just needs to know what memory it can write too, and in what format you 
want that rendered data to be. AggPas supports many render buffer formats. BGR, 
BGRA, RGB, RGBA, Gray8, rgb555, rgb565 etc etc. And if an existing render 
buffer format doesn't exist, it is really easy and quick to add a new one - 
just a few really simple procedures to implement.

See the pf_*.inc files for plenty of examples. The "pf_" prefix stands for 
"pixel format definition".


> I'm looking at it and I think getimage / putimage are just one byte per 
> pixel... maybe?

I'll see if I can get graph or ptcgraph working working here under FreeBSD, 
then I'll take a look at what pixel format they use.


Regards,
   Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-31 Thread James Richters
I was doing some tests with Putpixel and that seems to be a word in the format 
of RGBA with 4 bits each.I would think putimage would use the same format, 
but I haven't tested that yet.

I'm still a bit confused by putimage, since it only has an X and Y startpoint, 
how do you define the height and width of the bitmap? Getimage() specifies a 
rectangle, and imagesize() figures out how much memory you need, but I just 
don't what defines the size and shape of the image to putimage.

I managed to get the test out of the buffer and onto the screen with :

  function getBufItemAsByte(aDelta: Word): Byte;
  var
actualY: Integer;
thing:Byte;
  begin
actualY := ImageHeight - y - 1;
thing :=
  byte(buf[x * RGBA_Width + actualY * ImageWidth * RGBA_Width + aDelta]);
result:=thing shr 4;  //colors channels are reduced to 4 bits each, they 
are not correct
  end;

for x := 0 to ImageWidth - 1 do
   for y := 0 to ImageHeight - 1 do
   begin
  pixelcolor:=(getBufItemAsbyte(2) shl 12)+(getBufItemAsbyte(1) shl 8) 
+(getBufItemAsbyte(0) shl 4)+getBufItemAsbyte(3);
  putpixel(x,y,pixelcolor);
  end;


James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Tuesday, May 30, 2017 8:19 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-30 22:37, James Richters wrote:

> Putimage() takes
> Initial X position
> Initial Y position
> Pointer to beginning of memory bitmap

In that case the AggPas code should be even faster, because PutImage() only 
want a pointer to the bitmap data - thus no need to go through the slow FPImage 
code to generate a PNG or BMP image. The pixel-by-pixel conversions for FPImage 
is very slow.

>Size := ImageSize(10, 20, 30, 40);
>GetMem(Q, Size);   { Allocate memory on heap }

So you can do pretty much the same with AggPas then. Allocate the memory you 
need, and attach that as the rendering buffer or AggPas. As I mentioned before, 
AggPas just needs to know what memory it can write too, and in what format you 
want that rendered data to be. AggPas supports many render buffer formats. BGR, 
BGRA, RGB, RGBA, Gray8, rgb555, rgb565 etc etc. And if an existing render 
buffer format doesn't exist, it is really easy and quick to add a new one - 
just a few really simple procedures to implement.

See the pf_*.inc files for plenty of examples. The "pf_" prefix stands for 
"pixel format definition".


> I'm looking at it and I think getimage / putimage are just one byte per 
> pixel... maybe?

I'll see if I can get graph or ptcgraph working working here under 
FreeBSD, then I'll take a look at what pixel format they use.


Regards,
   Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-30 Thread Graeme Geldenhuys

On 2017-05-30 22:37, James Richters wrote:


Putimage() takes
Initial X position
Initial Y position
Pointer to beginning of memory bitmap


In that case the AggPas code should be even faster, because PutImage() 
only want a pointer to the bitmap data - thus no need to go through the 
slow FPImage code to generate a PNG or BMP image. The pixel-by-pixel 
conversions for FPImage is very slow.



   Size := ImageSize(10, 20, 30, 40);
   GetMem(Q, Size);   { Allocate memory on heap }


So you can do pretty much the same with AggPas then. Allocate the memory 
you need, and attach that as the rendering buffer or AggPas. As I 
mentioned before, AggPas just needs to know what memory it can write 
too, and in what format you want that rendered data to be. AggPas 
supports many render buffer formats. BGR, BGRA, RGB, RGBA, Gray8, 
rgb555, rgb565 etc etc. And if an existing render buffer format doesn't 
exist, it is really easy and quick to add a new one - just a few really 
simple procedures to implement.


See the pf_*.inc files for plenty of examples. The "pf_" prefix stands 
for "pixel format definition".




I'm looking at it and I think getimage / putimage are just one byte per 
pixel... maybe?


I'll see if I can get graph or ptcgraph working working here under 
FreeBSD, then I'll take a look at what pixel format they use.



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-30 Thread James Richters
>  * What parameters does its putimage() function take?
>  * Does in support PNG image format natively?

Putimage() takes
Initial X position
Initial Y position
Pointer to beginning of memory bitmap
Method to use (copy, AND, OR, XOR)  
See https://www.freepascal.org/docs-html/rtl/graph/putimage.html


Here's an example:
Var Q: Pointer;
   Bar(0, 0, (GetMaxX div 3), GetMaxY);
   Size := ImageSize(10, 20, 30, 40);
   GetMem(Q, Size);   { Allocate memory on heap }
   GetImage(10, 20, 30, 40, Q^);
   Readln;
   ClearDevice;
   PutImage(100, 100, Q^, NormalPut);
   readln;
   putimage(0,0,Q^,normalput);
   readln;

I can get this to work with getimage and putimage, but I have no idea how to 
build the image in memory and just use putimage.

I don't think it really supports any 'image formats'  it's just the TP 
compatible graphics thing for DOS style graphics.

I'm looking at it and I think getimage / putimage are just one byte per 
pixel... maybe?  so probably not what I want. 
I'm getting the feeling this is apples and oranges here, TP compatible memory 
map vs tcolor or tfpcolor or some other scheme with 4 bytes per pixel.
Maybe there just isn't anything canned that can do what I want?  Maybe I need 
to put the pixels on the screen myself using a nested loop and getpixel / 
putpixel and do whatever logic on my own.

James

-Original Message-
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Graeme Geldenhuys
Sent: Tuesday, May 30, 2017 4:55 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

On 2017-05-30 20:20, James Richters wrote:
> I've re-attached Graeme's sample slightly modified to open the 
> ptcgraph window, and attempt to use putimage on line 103 but when I 
> run it I get 217- access violation

I haven't downloaded or looked at ptcgraph at all. A few questions:

  * What parameters does its putimage() function take?
  * Does in support PNG image format natively?

I would imagine that it probably supports BMP only - comping from DOS and 
Windows background. If so, change the example program to use a BMP image 
instead of a PNG image. In your code you attached you are actually pushing the 
c variable, which is a TFPColor record of the last color retrieve from the 
AggPas buffer - so no surprise you are getting a AV error.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal 
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-05-30 Thread Graeme Geldenhuys

On 2017-05-30 20:20, James Richters wrote:

I've re-attached Graeme's sample slightly modified to open the
ptcgraph window, and attempt to use putimage on line 103 but when I
run it I get 217- access violation


I haven't downloaded or looked at ptcgraph at all. A few questions:

 * What parameters does its putimage() function take?
 * Does in support PNG image format natively?

I would imagine that it probably supports BMP only - comping from DOS 
and Windows background. If so, change the example program to use a BMP 
image instead of a PNG image. In your code you attached you are actually 
pushing the c variable, which is a TFPColor record of the last color 
retrieve from the AggPas buffer - so no surprise you are getting a AV error.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Implementing AggPas with PtcGraph

2017-05-30 Thread James Richters
>As I mentioned, AggPas can use allocated memory, array, a memory image etc as 
>its rendering buffer. If you want a graphical console program
>(eg: using Linux Console Framebuffer) using AggPas, then render your 
>application output via AggPas to a memory image, then bitblit that image
>to the console graphics output in whatever paint event you have available.

>Using AggPas with desktop GUI applications works pretty much identical as 
>above, except it bitblit's the memory image to the Window Canvas.

What is the best method for getting the memory image to a ptcgraph window?  I 
have been trying to figure how to use something like putimage to do this but 
I'm not sure how to do it or if it's even the best way.I think I probably 
need to convert the format of the memory buffer or something, but I can't 
figure out what to do.

I've re-attached Graeme's sample slightly modified to open the ptcgraph window, 
and attempt to use putimage on line 103 but when I run it I get 217- access 
violation

Any advice on how to get the image into the window is greatly appreciated.

James


Agg2DConsole.dpr
Description: Binary data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

  1   2   >