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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:37:47+00:00 2026-06-15T00:37:47+00:00

I am currently trying to write a program to encode text into a png

  • 0

I am currently trying to write a program to encode text into a png file only changing the least significant bit for each letter i want to encode in the picture, example
I have a ‘A’ which is 65 and I use 8 different bytes to encode the letter A. So
01010100<- 10101101<- 11011010<- 10101010<- each of these I change the last bit and the put
10110110<- 01010100<- 01010100<- 01010101<- them together so 65 is 01000001 each number by
the arrow is changed according to the 65.

If I should approach this a different way suggestions would be awesome :). This is just
a fun little project I wanted to do. But anyways back to my question.

When I read in a image that is only 4 pixels big I get like 680 bytes which is crazy, or at least I think it is, maybe im wrong? 4 pixels with ARGB at 8 bits each should be 16 bytes with a few bytes im sure to tell the operating system that it is a png and how to handle it. So i was expecting maybe like 30 bytes. Maybe less. Am I looking at this the wrong way? When png images are compressed do they become bigger if it is a small picture? And also, when I was saving it back to the Hard drive I always got a larger file. The original picture was 8,554 kb and then it turned into like 16kb when I saved it back. Here is the code for getting the image bytes and for saving the image. Maybe I am doing something wrong or I am just not understanding it correctly.

These are the ways I get the image (I tried 2 different things)

// BufferedImage img = ImageIO.read(new File(“image.png”));
BufferedImage img= robot.createScreenCapture(new Rectangle(1,2,2,2));

how I saved two different ways again.

try {
InputStream in = new ByteArrayInputStream(imgBytes);
BufferedImage bImageFromConvert = ImageIO.read(in);
ImageIO.write(bImageFromConvert, “png”, new File(
“image.png”));

//FileOutputStream fos = new FileOutputStream(“image.png”);
//fos.write(b);
//fos.close();
}catch(Exception e){}

How I got the bytes from the Image, again I tried two different ways, the second way that is commented out actually did give me the 16 bytes like I want but when I saved it the Windows couldnt Open it because it didnt know what it was i guess? Not sure, just said file not supported.

byte[] imageBytes = null;
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, “jpg”, baos );
baos.flush();
imageBytes = baos.toByteArray();
baos.close();
}catch(IOException e){System.out.println(e.getMessage());}

// imageBytes = ((DataBufferByte) image.getData().getDataBuffer()).getData();
return imageBytes;

Thanks!

  • 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-15T00:37:48+00:00Added an answer on June 15, 2026 at 12:37 am

    A png consists of a lot of image meta data as well as the raw image data. That is what is giving you crazy 680 bytes.

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

Sidebar

Related Questions

I'm trying to write a program with C# that sends text into other windows.
I am currently trying to write some code which turns C# Expressions into text.
I'm currently trying to write a program which will read words from a text
I am currently trying to write a program to store data about people into
I'm currently running into a bit of a problem. I'm trying to write a
I'm currently trying to write a voicechat program in python. All tips/trick is welcome
I am currently trying to write a program that is a connect four game
I am currently trying to write a program that alphabetizes strings. I have one
I am trying to write a DSL for a Ruby program. It currently works
I am currently trying to write a program which rounds a double variable 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.