5

I am going to load an image by provided file_path and then downsample it then save it. The whole thing should be done on android device.

I am in trouble to load an image on device and convert to halide::buffer.

Halide::Tools::load_image didn't work on android if I use it like

JNIEXPORT bool JNICALL Java_com_example_boxdownsample_MainActivity_downsample(
        JNIEnv *env, jobject obj, jstring file_path) { ...
    const char *path = env->GetStringUTFChars(file_path, NULL);
    std::string work_path = path;
    LOGD("the path is:%s", path);
    std::string input_file = work_path + "input.png";
    std::string output_file = work_path + "output.png";

    Halide::Buffer<uint16_t> input = Halide::Tools::load_image(input_file);//load_image didn't work ....
    int ret = box_downsample_halide(input, downsample_factor, output_u16); //box_downsample_halide is a static lib generated by halide generator
    ... } }

So, am I use it wrong? or I should load it use java(that would be bitmap format) then encode it to halide::buffer, but this seems a bit hard and indirect.

Is there any easier way to do it?

Thanks!

UPDATE: I found a way, in case who also need this, please go to my github

Lin.Chen
  • 73
  • 4
  • Greetings, I have been trying to get halide to compile under a newer version of android than the halide examples provide. It was mentioned that the code on your github that you linked in your question had an example of how to do it. Do you perhaps still have that code around? I notice it is no longer on github. Thanks much! – jllangston Jul 04 '20 at 12:44

0 Answers0