Code Monkey home page Code Monkey logo

gpu's People

Contributors

hu2prod avatar vird avatar

Watchers

 avatar

gpu's Issues

Feature request: use napi_png, napi_jpeg for image load (new API for buffer)

Proposal
new special buffer types:

  • buffer_image_rgb
  • buffer_image_rgba
  • buffer_image_rgb_list (same size all)
  • buffer_image_rgb_list_non_uniform

On creation can specify max_size_x, max_size_y, can_resize (only less than)

img_buf = ctx.buffer_image max_size_x=1920, max_size_y=1080, can_resize=false
img_list_buf = ctx.buffer_image_list max_size_x=1920, max_size_y=1080, max_count=100, can_resize=false
img_list_nu_buf = ctx.buffer_image_list_non_uniform max_size_x=1920, max_size_y=1080, max_count=100, can_resize=false
# autodetect API
img_buf.load "path.png"
img_buf.load "path.jpg"
img_buf.load "path.jpeg"
img_buf.load "path.raw" # will check size == max_size_x*max_size_y, otherwise can't detect size -> error
img_buf.load "path.PNG"
img_buf.load "path.JPG"
img_buf.load "path.png"
# any extension != png, jpg, raw -> error
# buffer manual only (prevent false positive raw as png)
img_buf.load_buf_raw buf # just buffer copy + size check
img_buf.load_buf_png buf
img_buf.load_buf_jpg buf
img_buf.load_buf_jpeg buf
# NOTE arg_list_set should be called before kernel call
# save (for buffer_image_rgb[a])
img_buf.save "path.png"
png_buf = img_buf.save_buf_png(reuse_buf)
png_buf = img_buf.save_buf_png(image_write_buffer_pool)
jpg_buf = img_buf.save_buf_jpg(reuse_buf)
raw_buf = img_buf.save_buf_raw(reuse_buf) # will check size, error if not match
# batch load
img_list_buf.load_list ["file1.png", "file2.png"]
img_list_buf.load_folder "folder" # note all files after fs.readdirSync will be sorded with sort (a,b)->a.localeCompare b
# batch save
img_list_buf.save_list ["file1.png", "file2.png"]
img_list_buf.save_folder "folder" # anonymous names would be generated

checklist

  • all buffers should have rgb and rgba versions (colorspace cast on load)
  • all versions should check that result is exactly same size as buffer
  • if can_resize, then bypass size check if size is less than original by x and y dimentions
  • provide buffer as argument will send 3 arguments: buf, size_x, size_y
    • buffer_image_rgb stores max_size_x/y and size_x/y (can_resize only allows max_size_x/y != size_x/y)
    • buffer_image_list 4th argument image_count
    • buffer_image_list_non_uniform 5th argument buf u32 image_size_list (u32 size_x, u32 size_y)
  • buffer_image_* can pass queue.h2d/d2h
  • buffer_image_list_non_uniform queue.h2d/d2h should transfer both buffers

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.