https://linen.dev logo
Join Discord
Powered by
# ceramic
  • a

    ambitious-knife-25690

    02/27/2023, 1:34 PM
    ahh, i'm referring to if a user does something like
    file://C...
    or maybe even a web url
  • b

    bright-gpu-74537

    02/27/2023, 1:34 PM
    https://github.com/haxeui/haxeui-core/blob/master/haxe/ui/util/ImageLoader.hx
  • a

    ambitious-knife-25690

    02/27/2023, 1:34 PM
    i think for these cases it makes sense to load the image
  • b

    bright-gpu-74537

    02/27/2023, 1:34 PM
    file:// will use imageFromBytes, so will http://
  • b

    bright-gpu-74537

    02/27/2023, 1:35 PM
    default will attempt that method above (first internal to the framework, then from haxe resource bytes)
  • a

    ambitious-knife-25690

    02/27/2023, 1:36 PM
  • a

    ambitious-knife-25690

    02/27/2023, 1:37 PM
    okay. did not expect that to "just work"
  • b

    bright-gpu-74537

    02/27/2023, 1:37 PM
    sure, you implemented imageFromBytes... so, done... everything that uses that (like http, file) will just work
  • b

    bright-gpu-74537

    02/27/2023, 1:40 PM
    remember once you implement "a few" (im sure you realise its not a few 🙂 ) anchor points into haxeui-core then the rest of the framework just does its thing... its doesnt care (or know) what ceramic is... it just says "ive got some bytes can you turn that into an image", it also doesnt really know what an image is, or how to display it, thats also delegated...
  • b

    bright-gpu-74537

    02/27/2023, 1:41 PM
    so i guess its more like "ive got some bytes can you turn that into what you think is an image" and then later "that thing you said is an image, here it is, can you display here"
  • a

    ambitious-knife-25690

    02/27/2023, 1:41 PM
    i was thinking "i've gotta add this stuff to ceramic's asset obj" lol
  • b

    bright-gpu-74537

    02/27/2023, 1:42 PM
    naw, bytes, something internal to the framework and "from image data" (ie, texture)
  • b

    bright-gpu-74537

    02/27/2023, 1:42 PM
    i think you've done all that except the last
  • b

    bright-gpu-74537

    02/27/2023, 1:42 PM
    ToolkitAssets.instance.imageInfoFromImageData
    - and that should be super simple to implement for you / ceramic
  • b

    billowy-waiter-28954

    02/27/2023, 1:43 PM
    @ambitious-knife-25690 Could be useful: https://github.com/ceramic-engine/ceramic-samples/blob/master/http-image/src/MainScene.hx
  • a

    ambitious-knife-25690

    02/27/2023, 1:44 PM
    okay, url works
  • a

    ambitious-knife-25690

    02/27/2023, 1:44 PM
    but local path doesn't
  • b

    bright-gpu-74537

    02/27/2023, 1:45 PM
    is the file defo there?
  • a

    ambitious-knife-25690

    02/27/2023, 1:45 PM
    yeah
  • b

    bright-gpu-74537

    02/27/2023, 1:46 PM
    ah, actually, i was wrong, it is a different function:
    Toolkit.assets.imageFromFile
  • b

    bright-gpu-74537

    02/27/2023, 1:46 PM
    i feel like that could be using from bytes as its default impl though
  • a

    ambitious-knife-25690

    02/27/2023, 1:46 PM
    ahah, and for that I have a previous hacky temp solution implemented
  • b

    bright-gpu-74537

    02/27/2023, 1:47 PM
    im actually not really sure why that functions exists... i might drop it... ill have to check the other backends first though
  • b

    billowy-waiter-28954

    02/27/2023, 1:48 PM
    Copy code
    haxe
    var bytes = ceramic.Files.getBytes('your/file/path')
  • a

    ambitious-knife-25690

    02/27/2023, 1:48 PM
    ohhh.....
  • b

    bright-gpu-74537

    02/27/2023, 1:48 PM
    oh, actually the default impl does use image from bytes... its just that you overrode it
  • a

    ambitious-knife-25690

    02/27/2023, 1:48 PM
    i just sent
    callback(null)
    and the image didn't load anyway
  • b

    bright-gpu-74537

    02/27/2023, 1:49 PM
    Copy code
    haxe
        public function imageFromFile(filename:String, callback:ImageInfo->Void) {
            #if sys
    
            if (isAbsolutePath(filename) == false) {
                var parts = haxe.io.Path.normalize(Sys.programPath()).split("/");
                parts.pop();
                filename = parts.join("/") + "/" + filename;
            }
            filename = haxe.io.Path.normalize(filename);
            if (sys.FileSystem.exists(filename) == false) {
                callback(null);
            }
    
            try {
                Toolkit.assets.imageFromBytes(sys.io.File.getBytes(filename), callback);
            } catch (e:Dynamic) {
                trace("Problem loading image file: " + e);
                callback(null);
            }
    
            #else
    
            trace('WARNING: cant load from file system on non-sys targets [${filename}]');
            callback(null);
    
            #end
        }
  • b

    bright-gpu-74537

    02/27/2023, 1:49 PM
    well, you still overrode that default impl in the AssetsBase class
  • a

    ambitious-knife-25690

    02/27/2023, 1:49 PM
    oohh it's implemented by default?
1...838485...124Latest