Code Monkey home page Code Monkey logo

Comments (9)

photopea avatar photopea commented on May 26, 2024

What do you mean? You should be able to use the current library from any place of your code.

from upng.js.

415848878 avatar 415848878 commented on May 26, 2024

I use upng on a game engine. I convert RGBA to png arraybuffer and save it as a file. The conversion process takes about 2 or 3 seconds. I don't want to jam the main thread. Is there any async method

from upng.js.

photopea avatar photopea commented on May 26, 2024

What kind of data do you store inside PNG images? If you have game screenshots, use JPG for them (the encoding would take 100ms and files are 5x smaller). We also have a method for producing valid PNGs without any compression (takes 10ms for any image, but the output size is always 4 Bytes per pixel), but it is not exposed in our API now.

To avoid using the main thread, you could call UPNG.js in a web worker.

from upng.js.

415848878 avatar 415848878 commented on May 26, 2024

I make mobile games without web worker, which can only be used in the main thread and requires PNG pictures,

from upng.js.

photopea avatar photopea commented on May 26, 2024

I think it is not possible to make Javascript run outside the main thread without a web worker.

from upng.js.

415848878 avatar 415848878 commented on May 26, 2024

Yes, but it can be executed in frames. This is a common strategy to prevent the game from jamming. The proportion setTimeout can skip to the next frame to continue execution. For example, if one frame is 16ms, you can skip to the next frame after 8ms.

from upng.js.

photopea avatar photopea commented on May 26, 2024

We do not have an option to pause the PNG encoding, and to do it in multiple steps :(

from upng.js.

photopea avatar photopea commented on May 26, 2024

You probably mean the CPU executing multiple threads on a single CPU core. But that is what Web Workers are for.

from upng.js.

415848878 avatar 415848878 commented on May 26, 2024

OK, thank you for your answer. At present, it can only be used like this. Thank you for your work.

from upng.js.

Related Issues (20)

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.