Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:08:12+00:00 2026-05-29T07:08:12+00:00

I use JNI calls to load PNG files with Android class Bitmap using this

  • 0

I use JNI calls to load PNG files with Android class Bitmap using this guide http://lol.zoy.org/blog/2011/3/2/load-pngs-using-android-ndk.
And this works flawlessly until i try to get pixel data from Bitmap. I just can’t create a jint array which will fit image data (512*256), app just crash on this line. I do some test and it works without crash only with jint arrays which size <= 85000 (on my HTC Desire).
I think it’s some out of memory error but i get no relevant error in logcat and i try to only create a jint array without any other code it crash too.

#include <jni.h>    

int load_image_png(const char* path, GLuint* width, GLuint* height, void** image_data){
//Skip part what works fine - get bitmap width and height
//width=512, height=256

 jintArray array = g_env->NewIntArray(width*height);//FAIL OVERHERE

 jint* pixels = g_env->GetIntArrayElements(array, 0);
 *image_data = pixels;

 //closing a bitmap work fine too

 return 0;

}

P.S. It will be awesome if someone can give alternative way of loading png from Java code (without pnglib and native functions like in http://androgeek.info/?p=275)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:08:14+00:00Added an answer on May 29, 2026 at 7:08 am

    Exceptions don’t occur automagically in JNI. You have to write code to trigger them. i.e. it stores the error somewhere and you have to add code to say where you want the exception to be triggered.

    http://java.sun.com/docs/books/jni/html/exceptions.html


    From http://www.google.co.uk/search?q=java+png+library

    http://code.google.com/p/javapng/

    http://code.google.com/p/pngj/

    I don’t know which is better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use JNI on Ubuntu 8.10, using Eclipse and gcc (the standard
Use case: user clicks the link on a webpage - boom! load of files
I'm starting to learn java's JNI to use with an android device. As I
I use this AES library (in C language), http://gladman.plushost.co.uk/oldsite/AES/aes-src-16-04-07.zip I follow this page and
I have a Java app that use a bunch of JNI calls to execute
I use the JNI to start a Java Application out of C. While this
What is the common way (or best practice) to optionally use JNI? E.g. I
use LWP::Simple; use Parallel::ForkManager; @links=( [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe,SweetHome3D-2.1-windows.exe], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg,SweetHome3D-2.1-macosx.dmg], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip,SweetHome3DViewer-2.1.zip], ); # Max 30 processes for
use this website a lot but first time posting. My program creates a number
I need your help to add some insight into JNI on Android. I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.