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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:58:06+00:00 2026-06-12T21:58:06+00:00

1.i get the android camera data convert to bitmao if (mBitmap == null) //create

  • 0

1.i get the android camera data convert to bitmao

if (mBitmap == null)        //create Bitmap image first time
        {
            Camera.Parameters params = camera.getParameters();
            width_ima = params.getPreviewSize().width;
            height_ima = params.getPreviewSize().height;                      
            mBitmap = Bitmap.createBitmap(width_ima, height_ima, Bitmap.Config.RGB_565);
            mRGBData = new int[width_ima * height_ima];
        }

        decodeYUV420SP(mRGBData, data, width_ima, height_ima);
        mBitmap.setPixels(mRGBData, 0, width_ima, 0, 0, width_ima, height_ima);

2.send the data with udp

ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); 

        mBitmap.compress(Bitmap.CompressFormat.JPEG, 50, byteStream);   // !!!!!!!  change compression rate to change packets size

        byte data[] = byteStream.toByteArray();
        Log.e(TAG, "SIZE: " + data.length);

        int nb_packets = (int) Math.ceil(data.length / (float)DATAGRAM_MAX_SIZE);
        int size = DATAGRAM_MAX_SIZE;

        /* Loop through slices */
        for(i = 0; i < nb_packets; i++) 
        {           
            if(i >0 && i == nb_packets-1) size = data.length - i * DATAGRAM_MAX_SIZE;

            /* Set additional header */
            byte[] data2 = new byte[HEADER_SIZE + size];
            data2[0] = (byte)frame_nb;
            data2[1] = (byte)nb_packets;
            data2[2] = (byte)i;
            data2[3] = (byte)(size >> 8);
            data2[4] = (byte)size;

            /* Copy current slice to byte array */
            System.arraycopy(data, i * DATAGRAM_MAX_SIZE, data2, HEADER_SIZE, size);        

            try 
            {           
                size_p = data2.length;
                DatagramPacket packet = new DatagramPacket(data2, size_p, serverAddr, 9000);
                socket.send(packet);

3.i receive the data on android mobile

while (true) 
        {           

            try {
                socket.receive(packet);
                System.out.println("已经收到信息了!!!");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }               
            byte[] data = packet.getData();         
            int frame_nb = (int)data[0];
            int nb_packets = (int)data[1];
            int packet_nb = (int)data[2];
            int size_packet = (int) ((data[3] & 0xff) << 8 | (data[4] & 0xff)); 

            if((packet_nb==0) && (current_frame != frame_nb))
            {
                current_frame = frame_nb;
                slicesStored = 0;               
                imageData = new byte[nb_packets * DATA_MAX_SIZE];
            }

            if(frame_nb == current_frame)
            {
                    System.arraycopy(data, HEADER_SIZE, imageData, packet_nb * DATA_MAX_SIZE, size_packet);
                    slicesStored++;             
            }

            /* If image is complete display it */
            if (slicesStored == nb_packets) 
            {                   
                ByteArrayInputStream bis = new ByteArrayInputStream(imageData);

            }

And my question is : how i can display the ByteArrayInputStream bis data on android mobile… Thank you for reply!

  • 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-12T21:58:07+00:00Added an answer on June 12, 2026 at 9:58 pm

    In order to convert ByteArrayInputStream to a jpeg image you can simply use the following code:

        ByteArrayInputStream bis = new ByteArrayInputStream(imageData);
        Bitmap bp=BitmapFactory.decodeStream(bis); //decode stream to a bitmap image
        yourImageView.setImageBitmap(bp); //set the JPEG image in your image view
    

    Hope this helps.. Thanks..

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

Sidebar

Related Questions

To retrieve the Android camera size I've used the following code: camera=Camera.open(); Parameters params
I would like to capture an image from the camera on Android, and send
I need to do the following: Get a picture using the camera from Android...
Hi i am developing real time image processing application on android. I am using
I am trying to get Android USB host mode to work; but I need
When I wanted to get Android source code, I knew that I have to
I cannot get some Android devices to wake up using the AlarmManager. Following the
I'm trying to get my Android.mk file to optimize the binaries: LOCAL_PATH := $(call
Is it possible to get a Android WebView to open a port like: 5984?
I'm trying to get an Android app to post highscores to Facebook, similar to

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.