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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:37:33+00:00 2026-05-27T15:37:33+00:00

This question is related to my previous question but you dont need to read

  • 0

This question is related to my previous question but you dont need to read that in order to understand it.

Now I was trying to convert bitmap into smaller parts and then save those smaller parts.

Issue I get is, Only the first part gets saved in the file whose size is way bigger than the full image. Below is the code I am using:

for (int i = 0; i < Image.getHeight(); i++)
{
    fout = new FileOutputStream(file, true);
    Bitmap temp = Bitmap.createBitmap(Image, 0, i,Image.getWidth(), 1);
    temp.compress(Bitmap.CompressFormat.PNG, 100, fout);
    fout.flush();
    fout.close();
}

The Code is pretty simple but i dont understand that why the only first row gets written in the file.

UPDATE::
Merlin and Deepak are right. I tried now with giving different names and all the parts were successfully written to different files. Now you know the problem, should i go for the removing of header from second chunk and removing of eof from first chunk or what?

  • 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-27T15:37:34+00:00Added an answer on May 27, 2026 at 3:37 pm

    I’m going to resist the urge to ask why on earth you are doing this as it is highly inefficient, so let’s have a look.

    So you are writing one line of pixels at a time but you are writing them to the same file repeatedly with the append flag set to true which is correct.

    What you have missed is the fact that when you write a bitmap you are writing is self contained. So a program reading th first line will expect that to be the entire bitmap.

    This is the equivalent of having an EOF marker in a text file. All the lines are being written but when reading it the reader gives up after the first EOF

    You would need to research the the structure of a PNG file to understand more fully what is happening

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

Sidebar

Related Questions

This is related to my previous question , but a different one. I have
Very much related to my previous question , but I found this to be
This question is related to a previous question of mine That's my current code
This question is related to the previous post. How to save file and read
This is related to my previous question but it is a different problem. I
This question is related to a previous question I asked, but it's a different.
This is related to a previous question , but it seems different enough to
This is semi-related to my previous question . As that previous question states, I
This question is related to my previous question in that question I used color
this is related to my previous question. I'm trying to build Phone application from

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.