Recent

Author Topic: Image2text  (Read 12216 times)

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Image2text
« Reply #15 on: June 25, 2016, 06:59:46 pm »
You can replace SetLength() + FillChar() with OutPut := StringOfChar(#32, TheSizeYouNeed)

Bart

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Image2text
« Reply #16 on: June 26, 2016, 10:18:59 pm »
You can replace SetLength() + FillChar() with OutPut := StringOfChar(#32, TheSizeYouNeed)

Bart

For some reason using this instead of SetLength + FillChar execution get's broken in some point...

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Image2text
« Reply #17 on: June 26, 2016, 11:54:22 pm »
That's weird since StringOfChar does in essence the same:
Code: [Select]
Function StringOfChar(c : Ansichar;l : SizeInt) : AnsiString;
begin
  SetLength(StringOfChar,l);
  FillChar(Pointer(StringOfChar)^,Length(StringOfChar),c);
end;

Bart

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Image2text
« Reply #18 on: June 27, 2016, 12:11:48 am »
Yes it's weird. But does not works for me.

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: Image2text
« Reply #19 on: June 27, 2016, 11:41:09 am »
The expression Pointer(StringOfChar) seems ambiguous to me. It could mean the address of the code of the function.

What about using Result variable instead?
Code: Pascal  [Select][+][-]
  1. Function StringOfChar(c : Ansichar;l : SizeInt) : AnsiString;
  2. begin
  3.   SetLength(Result,l);
  4.   FillChar(Pointer(Result)^,Length(Result),c);
  5. end;
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Image2text
« Reply #20 on: June 27, 2016, 03:26:19 pm »
That works, you should report it in bugtracker...

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: Image2text
« Reply #21 on: June 27, 2016, 04:05:23 pm »
Yes but it works for me.

What system are you using?
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Image2text
« Reply #22 on: June 27, 2016, 04:40:55 pm »
Yes but it works for me.

What system are you using?

Ok..

Windows, FPC 3.0 Lazarus svn 51630 (1.6).

It's working for me too, my fault. I not assigned the output string before.

did this:
Code: Pascal  [Select][+][-]
  1. StringOfChar(' ', ((3*Bitmap.Width + Length(LineEnding)) * Bitmap.Height));

instead of this:
Code: Pascal  [Select][+][-]
  1. output := StringOfChar(' ', ((3*Bitmap.Width + Length(LineEnding)) * Bitmap.Height));

and when testing your function I did correctly, now just deleted your function and works. Sorry  ::)

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: Image2text
« Reply #23 on: June 28, 2016, 12:38:45 am »
Ok, so all is fine.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018