Can we call image from drawable of android with native c++ code [closed]

asked 2014-04-28 03:13:29 -0600

FLY gravatar image

updated 2014-09-22 15:44:20 -0600

Can we read Image from android drawable with jni like if I am using opencv with c++ in native environment of android with eclipse. Suppose I have a main.cpp in jni folder and from main.cpp , Can I call the image from drawable like

Mat imread ("drawable\\2.png") // In jni code with c++

Or I can only call it from drawable in java environment on java programming side.

Drawable is where we put our images in eclipse

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-08-16 18:40:04.726634

Comments

1

hi, FLY, that won't work.

the drawable folder is inside your apk, which is kinda a zipped filesystem

now, cheesy c++ functions like imread can't read from a zip file (that probably comes unexpected to a java guy), so you will have to copy it to sdcard or similar first, then imread() it from there

(apart from that, you need 2 backward slashes on windows, but 2forward slashes are just plain wrong)

berak gravatar imageberak ( 2014-09-22 15:40:05 -0600 )edit

ah \\ :P , okay , well Thanks berak

FLY gravatar imageFLY ( 2014-09-22 15:42:31 -0600 )edit

i'm sure there's something in android.utils, that allows you to read a bitmap-> Mat from resources, just can't find it

berak gravatar imageberak ( 2014-09-22 15:50:02 -0600 )edit

I think to resize my input image with constant image (image in drawable) on jni c++ end (which is not looking possible) , so I think now its better to deal both of them on java end

FLY gravatar imageFLY ( 2014-09-22 15:59:00 -0600 )edit
1

well, no , that backslashes only apply on windows, you can never use them on android.

berak gravatar imageberak ( 2014-09-23 01:37:02 -0600 )edit
sturkmen gravatar imagesturkmen ( 2020-08-16 19:45:33 -0600 )edit