Giter Site home page Giter Site logo

graphics32 / graphics32 Goto Github PK

View Code? Open in Web Editor NEW
367.0 54.0 120.0 17.73 MB

Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.

Home Page: http://graphics32.org/

License: GNU Lesser General Public License v2.1

Pascal 98.48% Batchfile 0.01% Perl 0.10% Roff 1.40%
graphics 2d vector-graphics low-level delphi fpc object-pascal components graphics-library lazarus

graphics32's Introduction

Graphics32

Graphics32 is a graphics library for Delphi and Lazarus. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.

The documentation can be found at https://graphics32.github.io/Docs

This is the official GitHub fork of the original SourceForge repository. The latter can still be found at http://sf.net/projects/graphics32

Misc.

Delphinus-Support

License

This work is dual-licensed under MPL 1.1 or LGPL 2.1 with linking exception.

SPDX-License-Identifier: MPL-1.1+ OR LGPL-2.1-linking-exception+

graphics32's People

Contributors

adnsv avatar andersmelander avatar angusjohnson avatar chriss5 avatar corneliusdavid avatar curiouskit avatar cwbudde avatar djmaster avatar dummzeuch avatar eugenekryukov avatar eviljazz avatar exilon avatar faludiz avatar fathonysl avatar felipemdc avatar fernando-takeshi avatar gregspa avatar ithyx-ak avatar lamdalili avatar meanderix avatar mhbuur avatar micha137 avatar nandod avatar pnxtm avatar tednilsen avatar tommiprami avatar vdemidov avatar veftodii avatar zedxxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphics32's Issues

GetPixelXS: Crash on Delphi WIN64

Hello,

the Assembler part in GetPixelXS crashed with Access violation (Delphi Tokyo, Win64 without $PurePascal).

Steps to reproduce:

`
uses
GR32;

procedure TForm2.Button1Click(Sender: TObject);
var
Bitmap: TBitmap32;
C: TColor32;
begin
Bitmap:= TBitmap32.Create;
Bitmap.SetSize(32, 32);
C:= Bitmap.PixelXS[Fixed(1), Fixed(1)];
end;
`

Best regards
Dirk

Unusal BuildArc output

Hows it going Peeps,

I am writing a TBitmap32 helper class to add the methods Rectangle, Ellipse, Arc, etc, to TBitmap32 to reflect the Delphi TCanvas methods. I was implementing an Arc method as such,

procedure TBitmap32Helper.ArcFS( X, Y, StartAngle, EndAngle, Radius : TFloat; AColor : TColor32; 
    StrokeWidth : TFloat; Steps : Integer );
      var
        APoint : TFloatPoint;
        AArc : TArrayOfFloatPoint;

  begin
    APoint.X := X + 0.5;  // Add floating point offset
    APoint.Y := Y + 0.5;
    AArc := GR32_VectorUtils.BuildArc( APoint, StartAngle, EndAngle, Radius, Steps );
    GR32_Polygons.PolylineFS( Self, AArc, AColor, False, StrokeWidth );
  end;

This the output called with this procedure

PaintBox321.Buffer.ArcFS( 200, 200, 0, 180, 50, clRed32, 1.0, 6 );

untitled3

I read this issue

#37

and used the code supplied, but, the output was the same.

Adding 100 steps gives this result

untitled4

Nice spirograph but it is not was I was looking for.

Is there another was to paint Arcs?

Cheers my old mates.

TBitmap32 constructor access violation

When I try this -> Bmp32 := TBitmap32.Create(1920, 1080);

An Access violation occured, because that is going to TCustomMap Create constructor and FBackend was never created.

procedure TCustomBitmap32.ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer);
begin
{ FBackend is NIL }
FBackend.ChangeSize(Width, Height, NewWidth, NewHeight);
end;

I fixed it as follows;

TCustomBitmap32 = class(TCustomMap)
public
constructor Create(Width, Height: Integer);reintroduce; overload; virtual;
....
end;

constructor TCustomBitmap32.Create(Width, Height: Integer);
begin
Create;
SetSize(Width,Height);
end;

Thanks.

Angle Arc

image

Hi,
How do I draw a geometric arc like the one above? The BuildArc function does not behave as expected.

TPointerMap.Delete can have undefined result + off by one error

The code for TPointerMap.Delete is incorrect:

function TPointerMap.Delete(BucketIndex, ItemIndex: Integer): PData;
begin
  with FBuckets[BucketIndex] do
  begin
    Result := Items[ItemIndex].Data;

    if FCount = 0 then Exit;   <<-- error: how can result be valid if count = 0?

    Dec(Count);
    if Count = 0 then
      SetLength(Items, 0)
    else
    if (ItemIndex < Count) then
       //Oops off by 1 error!
      Move(Items[ItemIndex + 1], Items[ItemIndex], (Count - ItemIndex - 1) * SizeOf(TPointerBucketItem));
  end;
  Dec(FCount); <<-- The use of with makes this statement confusing.
end;

The code should be changed as follows:

{
  TPointerBucket = record
    Count: Integer;
    Items: TPointerBucketItemArray;
end;}

function TPointerMap.Delete(BucketIndex, ItemIndex: Integer): PData;
var
  Bucket: TPointerBucket ;
begin
    if FCount = 0 then Exit(nil);
    //Perhaps add some code to validate BucketIndex & ItemIndex?
    Assert(BucketIndex < Length(FBuckets));
    Bucket:= FBuckets[BucketIndex];
    if ItemIndex >= Bucket.
    Assert(ItemIndex < Length(Bucket.Items));
    Result := Bucket.Items[ItemIndex].Data;
    Dec(Bucket.Count);
    if Bucket.Count = 0 then
      SetLength(Bucket.Items, 0)
    else
     /// assume array like so: 0 1 2 3 4  , itemindex = 0
    /// result should be 1 2 3 4
    /// move(1,0,4) (because 4 items should be moved.
    /// Thus move (itemindex+1, intemindex, count-itemindex)
    if (ItemIndex < Bucket.Count) then
      Move(Items[ItemIndex + 1], Items[ItemIndex], (Bucket.Count - ItemIndex) * SizeOf(TPointerBucketItem));
  end;
  Dec(FCount);
end;

GR32_VectorUtils.pas has bug

procedures of BuildDashedLine():
Line 2430: if Length(Result[J]) = 0 then SetLength(Result, J);
Line 2527: if Length(Result[J]) = 0 then SetLength(Result, J);

in Result[J] where J might be less than 0 in some case.

GR32_VectorUtils.Circle method has a problem.

Hi,

I'm using the following code blocks to draw a circle on TBitmap32 (x:0,y:0) points.

Pts := Circle(0,0,35);
PolylineFS(Bitmap32, Pts, clBlack32, True, 3);

However, the drawn circle is drawn behind the specified coordinates. Half of the circle is in the minus coordinates of the TBitmap32.

Pts := Circle(35,35,35);

When I try this line of code, the x coordinate is drawn almost to the correct point, but Y point is still not in the correct coordinate.

I want this function to act like TCanvas.Ellipse. I tried a lot of things, but I wasn't successful.

Can you help me?

compile error in delphi2010

Compiling GR32_R.dproj (Release configuration)
[DCC Error] GR32_Layers.pas(1454): E2010 Incompatible types: 'TRect' and 'TFloatRect'
[DCC Fatal Error] GR32.pas(1088): F2063 Could not compile used unit '....\GR32_Layers.pas'

it is if IsRectEmpty()

Canvas32 Path looking strange

stange

Procedure DoPolyLine(const pfad: GR32_Paths.TFlattenedPath;
                           const data: TLineData;
                           const add:  boolean);
var maxl: cardinal;
    i:    cardinal;
begin
  if ( Assigned(pfad) and ( Length(data) > 1 ) ) then begin
    maxl:= High(data);
    if add then
      pfad.MoveTo(data[0])
    else
      pfad.LineTo(data[0]);
    for I := 1 to maxl do pfad.LineTo(data[i]);
  end;
end;

With some combinations of the strokewidth and the difference on x axis I get a strange looking graph (see upper trace), while different x spacing works perfect (lower trace)

Dependency on TBitmap for file storage operations.

I'm wondering whether it might be better to move away from TBitmap32's dependency on TBitmap for file storage operations. To that end I've written a module that does read and write BMP formats and tested it with Jason Summers' test BMP suite. Is this likely to be of interest? (I am aware that TBitmap does also read and write other formats eg ICO & CUR.)

error compiling on delphi 10.3.1

the problem is with the last version in GR32_PolygonsAggLite

[dcc32 Error] GR32_PolygonsAggLite.pas(1717): E2003 Undeclared identifier: 'GAMMA_TABLE'

a strange picture

error

I found a strange picture !
graphics32-2.0
TImage32.load get "Can't allocate DIB handle"
graphics32 RX1
TImage32.load is ok, but IDE-"save all" get "out of memory"

1

GR32_ColorGradients does not support alpha composition

The GR32_ColorGradients unit only uses the Blend* functions which are not suited if the result is to be used with alpha composition.
Instead the Merge* functions should be used.

As an alternative the desired Combine Mode must somehow be supplied to the Polygon Filler.
As far as I can see there's a deficiency in the current Polygon Filler API in that the Polygon Renderer, which knows and uses the destination Combine Mode, doesn't pass this information on to the Filler.

Solutions I can think of are:

  • Passing the Combine Mode as a parameter in the constructor.
    Breaking change, but probably not much of a problem since custom fillers will be rare.
  • Supplying the Combine Mode via a property.
    Backward compatible, but not very elegant.

[edit] Having looked at this some more I believe the best method would be to pass the Combine Mode from the Renderer to the Filler via the Filler.FillLineEvent as a parameter. This is a breaking change but a minor one.

property OnContextPopup missing on TImage32

see commit dated 21 feb 2010 16:24, file Source/GR32_Image.pas

{$IFDEF DELPHI5}
    property OnContextPopup;
{$ENDIF}

the lines above where removed (in 3 places) with description "removed delphi 5 support"

but I think the conditionnal define was here to allow compilation in delphi 4 and before
the property should have been kept and only the conditionnal define should have been removed

Path.arc always closes path

Hi,
I'm not sure if this is a bug or planned behavior.
canvas32.path.arc closes the path and ends the current path. So it acts like rectangle or circle (where this would make sense), but in my opinion the arc function should be able to integrate in a path to allow geometric figures.
This behavior is due to the use of the TCustomPath.polygon function in arc.
I just created a second version of arc, which calls a function called 'Polyline' where polyline does neither call ClosePath nor EndPath and the call to BeginPath is optional.

Tomy

TPolygon32

Hello,

I am sorry to ask such a question here but is the TPolygon32 class not supported anymore? I have some old code that use this class extensively and it appears that is missing from GR32_Polygons

Thank you very much for your time

TCustomLayer.SetLayerCollection does not change underlying FLayerCollection

The following code fixes the issue

procedure TCustomLayer.SetLayerCollection(Value: TLayerCollection);
begin
  if FLayerCollection <> Value then begin
    if Assigned(FLayerCollection) then begin
      if FLayerCollection.MouseListener = Self then begin
        FLayerCollection.MouseListener := nil;
      end;
      FLayerCollection.RemoveItem(Self);
    end;
    if Assigned(Value) then begin
      Value.InsertItem(Self)
    end;
    FLayerCollection:= Value;  // add this line.
  end;
end;

The bug is here:

procedure TCustomLayer.SetLayerCollection(Value: TLayerCollection);
begin
  if FLayerCollection <> Value then begin
    if Assigned(FLayerCollection) then begin
      if FLayerCollection.MouseListener = Self then
        FLayerCollection.MouseListener := nil;
      FLayerCollection.RemoveItem(Self);
    end;
    if Assigned(Value) then Value.InsertItem(Self);
  end;
  /// FLayerCollection is never set!
end;

Bug with Layer + Right Button click

Steps to reproduce:

  1. Open, compile and run graphics32\Examples\Layers\ImgView_Layers\ImgView_Layers.dpr
  2. File->New...-> click Ok
  3. Layers->New Bitmap Layer (or any)-> open
  4. Right click on the layer. Now try to click on any menu item or close the program.

What is the expected behavior?
A tap on the button should fire the click event.

What is the current behavior?
The first tap highlights the button. The second tap fires the click event.

Thus, buttons need to be tapped twice in order to fire the click event!
There is no such problem with the left click on the layer.

Is there any way to fix this abnormal behavior?
My current workaround is

procedure TMainForm.ImgViewMouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer);
begin
  if Button = mbRight then ReleaseCapture;
end;

Loop test with Float

In GR32_VectorUtils.pas, function BuildDashedLine there is this while loop

while DashOffset < 0 do
begin
Inc(DashIndex);
DashOffset := DashOffset + DashArray[DashIndex];
end;

Due to addition of floatnumbers DashOffset can become very small negative instead of 0
and index of DashArray will step over its range.
A floating error appears as secondary problem by adding random data from beyond DashArray limit.
Solution: use while DashOffset < -Epsilon do

To reproduce this error drop an Image32 and a Button on a form and use this

procedure TForm3.Button1Click(Sender: TObject);
var
Points: TArrayOfFloatPoint;
Dashes: TArrayOfFloat;
i: Integer;
W, H: Integer;
begin
Image321.Bitmap.SetSizeFrom(Image321);
Image321.Bitmap.Clear(clWhite32);
W := Image321.Bitmap.Width;
H := Image321.Bitmap.Height;

SetLength(Dashes, 2);
// Problem appears when Dashes have many decimal places
Dashes[0] := 10;
//Dashes[1] := 3; // works
Dashes[1] := Pi; // gives error

SetLength(Points, 2);

for i := 1 to 100 do
begin
Points[0] := FloatPoint(Random(W), Random(H));
Points[1] := FloatPoint(Random(W), Random(H));
DashLineFS(Image321.Bitmap, Points, Dashes, clRed32, False);
end;

end;

Crash when deleting layers

Hi,

I appear to have hit an issue when trying to delete layers. It seems that unless you delete layers in reverse order (from the last added to the first) an exception is thrown. I created the simplest application to test this and it is repeatable every time.

I created a simple form with a TImgView32 component (properties all at default) then a button which does the following:

procedure TMainForm.btnDeleteTestClick(Sender: TObject);
var
  Layer1: TCustomLayer;
  Layer2: TCustomLayer;
begin
  Layer1 := TCustomLayer.Create(ImageView.Layers);
  Layer2 := TCustomLayer.Create(ImageView.Layers);

  Layer1.Free;
  Layer2.Free;
end;

If I reverse the order (Layer2.Free then Layer1.Free) it works fine, but this way round it crashes every time. It's also the same whether I use TCustomLayer, TPositionedLayer, TBitmapLayer, or whatever.

Any idea what is causing this or if I'm doing something wrong? I'm running Delphi XE, by the way.

Thanks

function Circle not return the circle

this is the code:
function Circle(const P: TFloatPoint; const Radius: TFloat): TArrayOfFloatPoint;
begin
Circle(P, Radius, CalculateCircleSteps(Radius));
//fixed is: Result := Circle(P, Radius, CalculateCircleSteps(Radius));
end;

GR32_Text_VCL bugs

I started to use the 'new' '2.0.0 alpha' version of Graphics32. I've found that a new text rendering method avaiable in it (Intf.TextToPath). I started to use it and found that it is about 3 times faster that my old code with GDI+. This is the good point. The bad point is that I've found some bugs in GR32_Text_VCL.pas: (I use it with Delphi XE7 on Windows)

  • In function GlyphOutlineToPath
    Res := GetGlyphOutlineW(Handle, Glyph, GGODefaultFlags[UseHinting], Metrics, 0, nil, VertFlip_mat2); gives zero result for some characters (e.g. for a non breaking space character) which throws an error later when a 0 bytes memory allocated.
    I am not sure that this is the best way, but I corrected the check after it to:
    if not Result or not Assigned(Path) or (Res = 0) then Exit; and it solved my problem.

  • In procedure InternalTextToPath I've found the alignment buggy. When center or right alignment used it puts an unnecessary new line to the end of text which corrupts the alignment:
    if [(Flags and DT_HORZ_ALIGN_MASK)] * [DT_CENTER, DT_RIGHT] <> [] then NewLine(TextLen);
    I made a new AlignLine procedure which only do the alingnment and since then it works for me nicely.

I attached the GR32_Text_VCL.pas with my modifications (I marked the modified places by //WS).
GR32_Text_VCL.zip

This seems like a buffer overrun -- can anyone confirm?

In GR32_CONTAINERS there is a line using MOVE that seems to be grabbing more data than it should -- eg. let's look at the case of having 7 items in the Items array

Count Returns 7
But the item indices are 0 zero based.

So if we delete the 3rd item we would pass an item index of 2 and it would
MOVE Item3 into Item 2, and since it's a packed array it can move the rest of them as well by just specifying the data size which it does by (Count - ItemIndex) * SizeOf(TPointerBucketItem))

BUT (Count - ItemIndex) = 7-2 = 5 items

So it's trying to move items 3, 4, 5, 6, 7 into Item 2.

Only problem is that there is NO item 7, the items only go up to 6 because it's zero based. So it appears to me to be grabbing Memory that it doesn't necessarily own... or am I missing something?

I've included the original routine with my change and I'd like verification that I'm understanding this correctly and my fix makes sense.

Thanks for any input!

function TPointerMap.Delete(BucketIndex, ItemIndex: Integer): PData;
begin
  with FBuckets[BucketIndex] do
  begin
    Result := Items[ItemIndex].Data;
    if FCount = 0 then Exit;
    if Count = 1 then
      SetLength(Items, 0)
    else
 (* KJS CHANGED THE FOLLOWING: 
     Move(Items[ItemIndex + 1], Items[ItemIndex], (Count - ItemIndex) * SizeOf(TPointerBucketItem));
 because it was causing a buffer overrun? *)
      Move(Items[ItemIndex + 1], Items[ItemIndex], Pred(Count - ItemIndex) * SizeOf(TPointerBucketItem));
    Dec(Count);
  end;
  Dec(FCount);
end;

PolylineFS and TFloatRect

Hi Peeps,

Got this code,

Outline : TArrayOfFloatPoint;
ARectangle : TFloatRec;

ARectangle.Left := 10.0;
ARectangle.Top := 10.0;
ARectangle.Right := 200.0;
ARectangle.Bottom := 200.0;

OutLine := Rectangle( ARectangle );
PolylineFS( PaintBox321.Buffer, Outline, clLime32, True, 1.0 );

This renders the rectangle with a 2 pixel outline not 1 as I would assume as the StrokeWidth is set to 1.0.

Setting the StrokeWidth to 0.5 only seems to modify the Alpha value of the color not the StrokeWidth, which is still 2 pixels wide.

Great library by the way, someone needs to write a book.

Cheers me old mates.

ExtractSingleSpan crash

GR32_VPR

around line 160:
P := @Points[I];
X := Round(P.X); <--- P.X is a small negative number, X becomes -1

SpanData[x]... <--- x used to access array. Causes exception.

I draw a route (multiple lines between two points multiple times). When I pan right, causing the route to move left off screen, the crash happens.

I tried to set X := 0 (if < 0) but that eventually causes a crash somewhere else.

Can't install on C++Builder 10.2 Tokyo with Fatal Error.

  1. Set [Tools->Environment Options->Delphi Options->Library->32-bit Windows->Lib Path
  2. Open [RX2->GR32_R.dpk] with [Delphi Compiler->Output -C/C++ ->Generate all C++Builder files (including package libs)]
    ==>Build
    {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
    [dcc32 Fatal Error] GR32_R.dpk(3): E2280 Unterminated conditional directive

AVX version of the SSE routines

Our application uses AVX (VEX-prefixed) instructions. As you know, transition between SSE instructions that don’t have VEX prefix and VEX-prefixed AVX instructions involves huge state transition penalty. You may find more information at https://software.intel.com/en-us/articles/avoiding-avx-sse-transition-penalties

The VZEROUPPER, which is supposed to help avoid transition penalty, is very expensive (slow) on some processors, and there is no reliable way on how to detect whether it is expensive or cheap. Besides that, contrary to the logic, testing shows that on Kaby Lake processors, calling VZEROUPPER at least once in an application makes subsequent non-VEX-prefixed SSE instructions 25% slower.
So, the most reliable way to avoid the penalties that slow down the application is is just to avoid AVX-SSE transitions – for example, by prefixing all the instructions with the VEX prefix. So, all instructions will become vector and there will be no transitions and no need to call VZEROUPPER.
To accomplish that, we should detect if our CPU supports AVX, and, if it does, never call a single non-VEX-prefixed SSE instruction.

Please consider adding VEX code as an alternative for SSE code for 64-bit version of Graphics32.
Unfortunately, Delphi internal assembler doesn’t yet support AVX instructions, so I’ve put byte codes.
You can also put bytecodes, by ending instructions in another compiler.

I can help you with the implementation if you wish.

CombineCallBack should have a parameter for the original color

I withdraw this change request.
I made the change myself back in 2016 and the event was working as expected so I thought other people might find it useful. It seems that developers here are under great stress and find it difficult to communicate without being condescending.
Good luck with the project.

SIGFPE in LineFSP [patch provided]

Hi, I found a bug and solution for it. Attaching patch file.

There are two bugs actually:

  1. When calling LineFSP with parameters resulting in zero-length line, hypot returns 0 (correct), and then the code will try to divide by hypot return value without checking. Fixed by adding the check.

  2. When calling LineFSP with some particular values and with L=true, the hypot will cause SIGFPE, because for L=true, the second parameter is incorrectly typecasted, so the final second parameter is Single (and float version of hypot is called), but the first parameter is typecasted to Integer, so hypot gets Integer value thinking it is Single. For some values it may work, but for others it will be NaN, thus crashing. I fixed it by correcting Integer typecast for the second parameter in two places.

I haven't checked, but the same issues may occur in the other places of the code.

(Win32, FPC 3.0.4)

LineFSP_SIGFPE.patch.txt

CombineReg_SSE2() sometimes gives wrong value

Was using the GradientEditor by Alex Rabochy.
I realized occasionally TGradientEditor.GetColorAt() gives a green shade. Traced down to CombineReg_SSE2() TARGET_X86 giving the green component values smaller than it's supposed to be.
Now I make GetColorAt() use CombineReg_Pas() instead and everything seems fine again.

GR32_Blend.pas and GR32_ColorGradients.pas error compiling on Lazarus 1.8.0RC2 FPC 3.0.3

OS: Linux Ubuntu 16.04.2 LTS x64
File: GR32_Blend.pas

    PUNPCKLBW XMM4 XMM3
    MOV RAX, bias_ptr ;Error here, Line 3063:

@LoopStart:

Error MSG: GR32_Blend.pas(3063,23) Error: Generating PIC, but reference is not PIC-safe

Here all messages:

Compile package GR32_Lazarus 2.0: Exit code 256, Errors: 1, Warnings: 22, Hints: 6
GR32_Blend.pas(1949,24) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(1949,16) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(1950,6) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(1950,30) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(1951,26) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(1951,18) Hint: Conversion between ordinals and pointers is not portable
GR32_Blend.pas(2903,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(2969,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3063,23) Error: Generating PIC, but reference is not PIC-safe
GR32_Blend.pas(3165,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3173,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3256,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3264,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3311,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3350,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3459,37) Warning: range check error while evaluating constants (-72057589759737856 must be between 0 and 18446744073709551615)
GR32_Blend.pas(3557,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3566,30) Warning: Check size of memory operand "movq: memory-operand-size is 64 bits, but expected [128 bits]"
GR32_Blend.pas(3575,30) Warning: Check size of memory operand "movq: memory-operand-size is 64 bits, but expected [128 bits]"
GR32_Blend.pas(3600,31) Warning: Check size of memory operand "movq: memory-operand-size is 64 bits, but expected [128 bits]"
GR32_Blend.pas(3742,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3750,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3818,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3828,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3903,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(3913,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(4008,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(4014,2) Warning: Exported/global symbols should be accessed via the GOT
GR32_Blend.pas(4377,2) Warning: Exported/global symbols should be accessed via the GOT

Error 10.2 Tokyo

When i compile my application, it throws an error in GR32_Blend:

Inc(Cardinal(alpha_ptr), 16); --> Left side cannot be assigned to

Compiler warnings & errors with Delphi7

compiling GR32_DSGN_D7.dpk

[Warnung] GR32_ColorGradients.pas(2331): Rückgabewert der Funktion 'DelaunayTriangulation' könnte undefiniert sein
[Fehler] GR32_ColorPicker.pas(346): Eigenschaft 'ParentBackground' existiert nicht in Basisklasse
[Fehler] GR32_ColorPicker.pas(390): Eigenschaft 'ParentBackground' existiert nicht in Basisklasse
[Fehler] GR32_ColorPicker.pas(435): Eigenschaft 'ParentBackground' existiert nicht in Basisklasse
[Fehler] GR32_ColorPicker.pas(479): Eigenschaft 'ParentBackground' existiert nicht in Basisklasse
[Fehler] GR32_ColorPicker.pas(526): Eigenschaft 'ParentBackground' existiert nicht in Basisklasse
[Fataler Fehler] GR32_Reg.pas(62): Verwendete Unit '..\GR32_ColorPicker.pas' kann nicht compiliert werden

!!! Setting ParentBackground under comment eliminates the error messages...
{$IFNDEF FPC}
//property ParentBackground;
{$ENDIF}

may be some warnings can be eliminated...

compiling GR32_D7.dpk

[Warnung] GR32_VectorUtils.pas(1166): Rückgabewert der Funktion 'DelaunayTriangulation' könnte undefiniert sein
[Warnung] GR32_VectorUtils.pas(2063): Variable 'Arc' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2240): Variable 'P1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2240): Variable 'E1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2240): Variable 'E2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2240): Variable 'P2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2270): Variable 'Normals' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2270): Variable 'P1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2270): Variable 'P2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2302): Variable 'P1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2302): Variable 'E1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2302): Variable 'E2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2302): Variable 'P2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2332): Variable 'Normals' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2332): Variable 'P1' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VectorUtils.pas(2332): Variable 'P2' ist möglicherweise nicht initialisiert worden
[Warnung] GR32_VPR.pas(524): Variable 'Poly' ist möglicherweise nicht initialisiert worden

minor bug with Wrap

The function GR32_LowLevel.Wrap(Value, Max: Single): Single; may produce infinite loop when Max parameter is 0 .

TBitmap32.Assign issue - loss of transparency.

The problem is that the PNG is incorrectly converted to TBitmap32, losing the transparency information in transit. Comparison of Assign() behavior for TBitmap32 and TBitmap:

procedure TForm1.Button8Click(Sender: TObject);
var
  bmp32: TBitmap32;
  bmp: TBitmap;
  wic: TWICImage;
begin
  bmp32 := TBitmap32.Create(TMemoryBackend);
  bmp := TBitmap.Create;
  wic := TWICImage.Create;
  try
    wic.LoadFromFile('overlay.png'); // transparent PNG
    // not OK
    bmp32.Assign(wic);
    bmp32.SaveToFile('BMP32.bmp'); // !!! nontransparent .bmp
    img1.Bitmap.Assign(bmp32); // !!! nontransparent TImage32
    // OK
    bmp.Assign(wic);
    bmp.SaveToFile('BMP.bmp'); // transparent .bmp
    img2.Bitmap.Assign(bmp);  // transparent TImage32
  finally
    wic.Free;
    bmp32.Free;
    bmp.Free;
  end;
end;

Here is a screenshot of the result:
screenshot

The original overlay.png file:
overlay

Is there any way to fix this issue?
Thanks.

AddRoundedJoin inserts a miter join

If the user decides to use round joins, the joints should be round indeed. However, in case of 'angle is concave' (<- comment from the code), a miter joint is used instead.

While this works well for low miter limits, it does not for high miter values. In this case a sharp spike ruins the visual appearance.

This issue relates to issue #45 as it is the reason for the odd results.

BlendMemEx($FFxxxxxx, 0, 255) loses alpha

The operation BlendMemEx($FF494949, 0, 255) produces different results depending on which implementation is used - and only the pascal versions produce the correct result.

Test case

  Color := 0;
  BlendMemEx_Reference($FF494949, Color, 255);
  Assert(Color = $FF494949);

Results

Function Result Valid
BlendMemEx_Reference $FF494949 Correct
BlendMemEx_Pas $FF494949 Correct
BlendMemEx_ASM $00494949 Wrong
BlendMemEx_MMX $FE494949 Wrong
BlendMemEx_SSE2 $FE494949 Wrong

The problem can be seen when rendering a polygon filled with an opaque gradient onto a transparent/clear bitmap. The resulting polygon should be opaque but isn't.

Considering that there appears to be an (out of date) unit test that verifies this function, it's a bit strange that this problem hasn't been discovered before...

Using GR32PNG

I managed to install one of your previous versions of GR32, with packages RSXE5 and DSGN RSXE5 and the problem with loading an image luckily dissapeared. I tried to get png transpareny, so in project manager I add GR_32Png.pas and GR32_PortableNetworkGraphics.pas (form your GR32PNGmaster ) to the project. Compiler asks for all GR32 dcu files so I add them to project folder. After compiling, I still get unknown picture file extension (.png), when trying to load the image. Hmmmm?

Tokyo still fails to compile - missing definitions

The Tokyo compilation still fails.

I have a feeling that this block is missing from the GR32_Compiler.inc file.

{$IFDEF COMPILERRX2}
  {$DEFINE COMPILERRX2_UP}
...
  {$DEFINE COMPILER6_UP}
{$ENDIF}

VER_LATEST is also set to RX1 and not RX2

And this block might be missing from the end:

{$IFDEF COMPILERRX2_UP}
  {$DEFINE COMPILERRX2}
{$ENDIF}

Can't install on Delphi 10.2 Tokyo Starter

Please help, how to install graphic32 on Delphi 10.2 Tokyo Starter? or is it still not yet supported?
Trying to use XE8 source dpk .. well yeah got stopped in line "Graphics32 may only be installed with Delphi/BCB 6 (or higher) or Free Pascal / Lazarus". I remember was able to use old version of gr32 but forgot how to do it...

Text quality is poor on transparent buffer

Hi,

As the title. Drop a paintbox32 into form. Here is the code for PaintBuffer event:

var
  TextBuffer: TBitmap32;
begin
  PaintBox321.Buffer.Clear(Color32(clBtnFace));

  TextBuffer := TBitmap32.Create;
  TextBuffer.SetSize(100, 100);
  TextBuffer.DrawMode := dmTransparent;
  TextBuffer.CombineMode := cmBlend;
  TextBuffer.Clear(0);

  TextBuffer.Font.Color := clRed;
  TextBuffer.Textout(0, 0, 'TEST STRING');

  TextBuffer.RenderText(0, 30, 'TEST STRING', 4, clRed32);

  TextBuffer.Canvas.Font.Color := clRed;
  TextBuffer.Canvas.Brush.Style := bsClear;
  TextBuffer.Canvas.TextOut(0, 60, 'TEST STRING');

  TextBuffer.DrawTo(PaintBox321.Buffer, 0, 0);

  TextBuffer.Free;

end;

Result:

capture

Expectation:

capture

Tried for other DrawMode & CombineMode. No success.

TNotifiablePersistent. FLock is not initialized in TCustomPolygonRenderer.Create

File: GR32_Polygons.pas
line: 1615
constructor TCustomPolygonRenderer.Create;
begin

end;

The inherited constructor of TCustomPolygonRenderer is not called -> TNotifiablePersistent. FLock is not initialized with a InitializeCriticalSection(FLock) call, but at the end of the object live time, the inherited destructor is called and make a Win-API call DeleteCriticalSection(FLock).

My suggestion: Delete the empty constructor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.