Recent

Author Topic: How is the fastest way to convert array to image canvas data?  (Read 16793 times)

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: How is the fastest way to convert array to image canvas data?
« Reply #15 on: February 19, 2014, 04:45:34 pm »
Try it:
invalidate - 55
not invalidate - 60

OpenGL is slower than previous. I do not understand it. :(
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: How is the fastest way to convert array to image canvas data?
« Reply #16 on: February 19, 2014, 05:14:51 pm »
The uploaded zip isn't using OpenGL though? Also i notice that the rendered area goes outside the form's right boundary. I get 64 with or without invalidate, but that's just my computer...

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: How is the fastest way to convert array to image canvas data?
« Reply #17 on: February 19, 2014, 05:47:57 pm »
It is previous code. OpenGL is without invalidate checkbox.
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How is the fastest way to convert array to image canvas data?
« Reply #18 on: February 19, 2014, 06:02:42 pm »
invalidate - 55
not invalidate - 60
This is because you're counting Timer events :)
The FPS counter needs to be placed at the actual painting code.

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: How is the fastest way to convert array to image canvas data?
« Reply #19 on: February 19, 2014, 06:58:25 pm »
Thank you all for your help.

Counting in FormPaint:
invalidate - 110 FPS
not invalidate 62 FPS

OpenGL code no changes.

Thank you all.
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How is the fastest way to convert array to image canvas data?
« Reply #20 on: February 19, 2014, 07:04:30 pm »
OpenGL code no changes.
That doesn't sound right.
OpenGL code also has "Idle" event added. So the "paint" should happen more often than "FormPaint"

Please count FPS for OpenGL at TForm1.OpenGLControl1Paint procedure.

... btw. if OpenGL shows a better FPS now, you could add the same on Idle event for Non-GL example.
In general, video intensive applications (such as games or video players) never use Timer Events to refresh the frame, instead they either paint as much as possible or on VSync signal.
(In the gl example I'm using "idle" to draw "as much as possible")

reinerr

  • New Member
  • *
  • Posts: 37
Re: How is the fastest way to convert array to image canvas data?
« Reply #21 on: February 24, 2014, 05:09:41 am »
I'm just wondering, the original poster is targeting an 8-bit system. Would such a system have hardware OpenGL support or will it be falling back to software rendering anyway?

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: How is the fastest way to convert array to image canvas data?
« Reply #22 on: February 24, 2014, 08:44:40 am »
I'm just wondering, the original poster is targeting an 8-bit system.

No he's not, he's emulating an 8 bit system:
Quote
(emulation of 8-bit computer).
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

macjone

  • Newbie
  • Posts: 2
Re: How is the fastest way to convert array to image canvas data?
« Reply #23 on: March 07, 2014, 03:13:59 am »
fast enough?

I guess the truth is not about the fastest way of converting one image format to another, but about fastest way to render image. That's OpenGL for cross-platform.


Yes, and which one do you think is faster to render image, byte[] or stream? By the way, I do not know following link can offer some insight for you.

http://stackoverflow.com/questions/17352061/fastest-way-to-convert-image-to-byte-array

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How is the fastest way to convert array to image canvas data?
« Reply #24 on: March 07, 2014, 05:13:40 am »
Yes, and which one do you think is faster to render image, byte[] or stream? By the way, I do not know following link can offer some insight for you.

http://stackoverflow.com/questions/17352061/fastest-way-to-convert-image-to-byte-array
it depends on the "stream". If stream is memory stream, then there won't be any difference.
If stream is a file stream, most likely byte[] is faster (since byte[] is in memory)

 

TinyPortal © 2005-2018