Recent

Author Topic: BGRABitmap NoGUI  (Read 7490 times)

raulik

  • New member
  • *
  • Posts: 9
BGRABitmap NoGUI
« on: October 13, 2016, 03:30:45 pm »
Hello,
i have installed BGRABitmap NoGUI on Win64 and try to crosscompile for Linux/64 NoGui Console app.
Have somethink bad, compilation's dona ok, but run ends with

An unhandled exception occurred at $00000000004E8997:
EInvalidOp: Invalid floating point operation
  $00000000004E8997
  $0000000000515957 line 373 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc
  $000000000051BE09 line 1531 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc
  $0000000000468CD9

When i use BGRABitmap or some other units. When i dont use it, aplication runs ok.
Linux is Ubuntu server.

Any idea ??

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #1 on: October 13, 2016, 03:41:56 pm »
Don't know why, but the error line is :
power(255, GammaExpFactor);

Tried :
  try
    Writeln('power : ' + FloatToStr(power(255, GammaExpFactor)));
  except
    on E:Exception do Writeln('ERROR : ' + E.Message);
  end;

it writes :

ERROR : Invalid floating point operation


circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: BGRABitmap NoGUI
« Reply #2 on: October 13, 2016, 07:45:26 pm »
Maybe it is a bug of the cross-compiler.

Code: Pascal  [Select][+][-]
  1. power(255, GammaExpFactor)
can be replaced by
Code: Pascal  [Select][+][-]
  1. exp(ln(255)*GammaExpFactor)

Does that also produce a runtime error?
Conscience is the debugger of the mind

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #3 on: October 13, 2016, 08:26:37 pm »
Still the same error

An unhandled exception occurred at $00000000005145AB:
EInvalidOp: Invalid floating point operation
  $00000000005145AB line 373 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc
  $000000000051AA69 line 1531 of ../libraries/BGRABitmap/bgrabitmap/bgrapixel.inc

I dont have posibility of compile on destination system directly, because of this, i'm using crosscompile.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: BGRABitmap NoGUI
« Reply #4 on: October 13, 2016, 08:53:30 pm »
Lazarus 1.6 fpc 3.0 or trunk?

Works as 32 bit cross compiling?

You can install Ubuntu Server in a virtual machine and compile directly in the target os if you want.

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #5 on: October 13, 2016, 09:08:33 pm »
I think, that lazarus 1.6 with fpc 3.0 - i use fpcup, so i dont know this exactly. Lazarus is 64bit, fpc too. Crosscompile to Linux/64.

Lazarus about say :

Lazarus 1.6 r51630 FPC 3.0.0 x86_64-win64-win32/win64 - from which i'm not very wise.

I tried to compile to Linux/32 (not very happy, because of memory need of this script (large image manipulation), that's the reason for what i need to run this on the server, not my computer), but i dont have Crosscompile to Linux/32 installed and absolutely dont know how to install :) Sorry, i'm very new in Lazarus, i was delphi programer, but... This summer i moved to Lazarus, so i'm very happy to have something done with crosscompile.

There is not problem to install fpc on this server - that my own, but i',m not friendly with fpc this time, for compilation this app from commandline - lot of packages, lot of units - aprox 300 000 lines of code.

I can aprove, that on win64, there is not this bug.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: BGRABitmap NoGUI
« Reply #6 on: October 13, 2016, 11:11:28 pm »
I'm running ubuntu 32 and nothing happens.

What if you comment the line 1531?

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #7 on: October 14, 2016, 11:31:25 am »
Then the skript runs (commented out whole his work, so only loading of BGRABitmap unit is tested).

But what about this gamma disconfiguration ?

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: BGRABitmap NoGUI
« Reply #8 on: October 14, 2016, 12:13:45 pm »
Gamma correction is to improve the color and brightness computation, but it is not necessary.

However there need to be some initialization.

@raulik:
I invite you to try the following. Add the following procedure next to procedure BGRASetGamma:
Code: Pascal  [Select][+][-]
  1. procedure BGRANoGamma;
  2. var i: integer;
  3. begin
  4.   GammaExpFactor := 1;
  5.   for i := 0 to 255 do
  6.     GammaExpansionTab[i] := (i shl 8) + i;
  7.   for i := 0 to 65535 do
  8.     GammaCompressionTab[i] := i shr 8;
  9. end;

And at the end of bgrapixel.inc, in the INCLUDE_INIT part, replace the call to BGRASetGamma by BGRANoGamma:
Code: Pascal  [Select][+][-]
  1. {$IFDEF INCLUDE_INIT}
  2. {$UNDEF INCLUDE_INIT}
  3.   BGRANoGamma();
  4. {$ENDIF}
Conscience is the debugger of the mind

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #9 on: October 14, 2016, 12:41:57 pm »
Many thanks, will try it. This time i'm searching for some else  "Invalid floating point operation" which is not shows on windows.

So, the problem is more deeply, because next IFOP is from :

round(filter.i['Treshold'] * 655.35)

so somethink bad is about FP operation.

Somethink what i should check ?

EDIT 2:
I dont understand this totally. When i try to do somethink like :

  function test(const x : byte; const y : real) : word;
  begin
    result := Round((x*y));
  end;

   Write('Test(82,655.35) = ');
   Writeln(IntToStr(test(82,655.35)));

On beginning of my code, that;s runs ok.

but i deep of my code :
   tresh := filter.i['Treshold'];
   Log('tresh = ' + IntToStr(tresh));

   Log('tresh * 655.35 = ');
   Log(FloatToStr(tresh*655.35));

   Log('round(tresh * 655.35) = ');
   Log(IntToStr(round(tresh*655.35)));

results in :
2016.10.14 13:36:36.151 - filter.i[Treshold] = 82
2016.10.14 13:36:36.151 - tresh = 82
2016.10.14 13:36:36.151 - tresh * 655.35 =
2016.10.14 13:36:36.151 - Exception on deploying image Invalid floating point operation


EDIT3:

function test(const x : byte; const y : real) : word;
begin
  result := Round((x*y));
end;


var tresh : byte;

   tresh := filter.i['Treshold'];
   Log('1)tresh = ' + IntToStr(tresh));

   Log('2)Test(82,655.35) = ');
   Log('2)'+IntToStr(test(82,655.35)));

   Log('3)82 * 655.35 = ');
   Log('3)'+FloatToStr(82*655.35));

   Log('4)test(trash, 655.35) = ');
   Log('4)'+IntToStr(test(tresh,655.35)));

   Log('5)tresh * 655.35 = ');
   Log('5)'+FloatToStr(tresh*655.35));

   Log('6)round(tresh * 655.35) = ');
   Log('6)'+IntToStr(round(tresh*655.35)));

results :
2016.10.14 13:58:23.914 - 1)tresh = 82
2016.10.14 13:58:23.914 - 2)Test(82,655.35) =
2016.10.14 13:58:23.914 - 2)53739
2016.10.14 13:58:23.914 - 3)82 * 655.35 =
2016.10.14 13:58:23.914 - 3)Nan
2016.10.14 13:58:23.914 - 4)test(trash, 655.35) =
2016.10.14 13:58:23.914 - 4)53739
2016.10.14 13:58:23.914 - 5)tresh * 655.35 =
2016.10.14 13:58:23.915 - Exception on deploying image Invalid floating point operation

So there is difference between direct math and math in function test.

And other bug is, that the same error i have foud on line like :

                fn += ifthen(filterNeedFilename<>'',filterNeedFilename,FormatFloat('0000', i)+'.jpeg');

I is word.
« Last Edit: October 14, 2016, 02:21:59 pm by raulik »

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #10 on: October 14, 2016, 03:43:12 pm »
Lazarus 64bit, FPC 32bit with Crosscompile to Linux64bit is good - so the bugs are only in fpc64.

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: BGRABitmap NoGUI
« Reply #11 on: October 14, 2016, 04:59:30 pm »
I would suggest to report on the bugtracker with a test program and detailled explanation on the compilation method.
Conscience is the debugger of the mind

raulik

  • New member
  • *
  • Posts: 9
Re: BGRABitmap NoGUI
« Reply #12 on: October 14, 2016, 06:03:34 pm »
Will try to reproduct this errors with test app next week. This time i changed fpc from 64bit to 32bit - don't know exactly how to change it back and i'm now happy, that the ppu cheksum changed errors leave. So for best, i need some virtual win with fpc install.

 

TinyPortal © 2005-2018