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 9237825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:37:20+00:00 2026-06-18T07:37:20+00:00

Hi my task is to display a set of decoded frames in android. In

  • 0

Hi my task is to display a set of decoded frames in android. In my native code i have a character(char ) pointer which holds the address of the decoded frame. I want to display this frame on my device so i got a hint from:
Displaying YUV Image in Android
hence in my activity class i wrote the following function:

public void displayFrame(byte[] data, int fwidth,int fheight){

    ImageView frameImgView=(ImageView) findViewById(R.id.imageView2);

    ByteArrayOutputStream out=new ByteArrayOutputStream();
    YuvImage yuvimg=new YuvImage(data, ImageFormat.NV21, fwidth, fheight, null);
    yuvimg.compressToJpeg(new Rect(0, 0, fwidth, fheight), 100, out);
    byte[] imageBytes = out.toByteArray();
    Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
    frameImgView.setImageBitmap(image);
    return;
}

Hence from my native code i need to call this function in java. From the link:
http://www.altdevblogaday.com/2011/12/09/running-native-code-on-android-part-1/
i got to know how to call a java function from native c.
However to call a java function we need an environment variable to do that. Im my java class i hav declared the main function as native and generated a header for that main function:

JNIEXPORT jint JNICALL Java_com_example_decoder_Decoder_mainFunction(JNIEnv *env, jclass jobj, jint argc, jstring argv1, jstring argv2);

however my mainFunction calls a function “fwriter(some pointer, some pointer)” which has a pointers as parameters. How do i get environment variable for the same. I know that in java class i need to declare “fwriter” function as native but what do i represent pointers as??

eg: my c function is:

void fwriter(int *ptr, char *ptr)
{
  ....
}

In my java class how do i declare this function as native??
Please help.
Any other methods to diaplay YUV in java/Android will also be appreciated.
Thank you.

  • 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-06-18T07:37:22+00:00Added an answer on June 18, 2026 at 7:37 am

    Whilst JPEG encoding and decoding may be hardware accelerated on most phones, I would expect a simple RGB->YUV conversion for-loop you wrote yourself to be much faster (fast enough even in Java without using a native library) and simpler.

    Here is the formula. If you are using OpenGLES to display, consider using a fragment shader to do the conversion on-the-fly.

    Finally, here’s the integer-only code you can use on the CPU:

    Ytmp =      4768 * (Y - 16);
    R = (Ytmp + 6537 * (V - 128)) >> 12;
    G = (Ytmp - 3330 * (V - 128) - 1602 * (U - 128)) >> 12;
    B = (Ytmp + 8266 * (U - 128)) >> 12;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a task to display an image, which is placed to a Google
I have the fllowing requirement, I have a model called Task to display user
Task at hand — I have three versions of some code, developed by different
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
Task: I have a camera mounted on the end of our assembly line, which
I have been trying to execute the following code. Though the task is trivial,
I have a Microsoft Access form which will display a Microsoft Word app with
I have quite simple task to accomplish - I have to set up the
I do have I simple Silverlight Task: Display a List of Supplier objects in
I have an app that is set up to display an entry from a

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.