Skip to main content
edited body; added 1 character in body; deleted 3 characters in body; deleted 1 character in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232
private static byte[] BitsFromImage(string fileName) {
  // Note, that .Net will convert png to BMP
  using var bmp = new Bitmap(fileName); 

  var bmpData = bmp.LockBits(
    new Rectangle(0, 0, bmp.Width, bmp.Height), 
    ImageLockMode.ReadOnly, 
    bmp.PixelFormat);

  var bytes = bmpData.Stride * bmp.Height;

  var rgbValues = new byte[bytes];

  Marshal.Copy(bmpData.Scan0, rgbValues, 0, bytes);

  // We want RGB oderorder, not deafultdefault BGR
  for (var i = 0; i < bytes; i += 3)
    (rgbValues[i], rgbValues[i + 1], rgbValues[i + 2]) = 
       (rgbValues[i + 2], rgbValues[i + 1], rgbValues[i]);

  // We want LSBs only 
  for (var i = 0; i < bytes; ++i)
    rgbValues[i] = (byte)(rgbValues[i] & 1);

  return rgbValues;
}
   // Put the right file name here
using var image = ImageToBmp(@"C:\Image2.png");
   
image.Save(@"C:\Solution.bmp");
private static byte[] BitsFromImage(string fileName) {
  // Note, that .Net will convert png to BMP
  using var bmp = new Bitmap(fileName); 

  var bmpData = bmp.LockBits(
    new Rectangle(0, 0, bmp.Width, bmp.Height), 
    ImageLockMode.ReadOnly, 
    bmp.PixelFormat);

  var bytes = bmpData.Stride * bmp.Height;

  var rgbValues = new byte[bytes];

  Marshal.Copy(bmpData.Scan0, rgbValues, 0, bytes);

  // We want RGB oder, not deafult BGR
  for (var i = 0; i < bytes; i += 3)
    (rgbValues[i], rgbValues[i + 1], rgbValues[i + 2]) = 
       (rgbValues[i + 2], rgbValues[i + 1], rgbValues[i]);

  // We want LSBs only 
  for (var i = 0; i < bytes; ++i)
    rgbValues[i] = (byte)(rgbValues[i] & 1);

  return rgbValues;
}
   // Put the right file name here
using var image = ImageToBmp(@"C:\Image2.png");
  image.Save(@"C:\Solution.bmp");
private static byte[] BitsFromImage(string fileName) {
  // Note, that .Net will convert png to BMP
  using var bmp = new Bitmap(fileName); 

  var bmpData = bmp.LockBits(
    new Rectangle(0, 0, bmp.Width, bmp.Height), 
    ImageLockMode.ReadOnly, 
    bmp.PixelFormat);

  var bytes = bmpData.Stride * bmp.Height;

  var rgbValues = new byte[bytes];

  Marshal.Copy(bmpData.Scan0, rgbValues, 0, bytes);

  // We want RGB order, not default BGR
  for (var i = 0; i < bytes; i += 3)
    (rgbValues[i], rgbValues[i + 1], rgbValues[i + 2]) = 
       (rgbValues[i + 2], rgbValues[i + 1], rgbValues[i]);

  // We want LSBs only 
  for (var i = 0; i < bytes; ++i)
    rgbValues[i] = (byte)(rgbValues[i] & 1);

  return rgbValues;
}
// Put the right file name here
using var image = ImageToBmp(@"C:\Image2.png");
 
image.Save(@"C:\Solution.bmp");
added 40 characters in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232

Where we can see Key and Kite.

Where we can see Key and Kite.

added 13 characters in body; added 36 characters in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232

Answer:

Having thesesthese bits we can easily implement a decoder for the 1st challenge:

If we run the imageroutine and save the image into a file

   // Put the right file name here
using var image = ImageToBmp(@"C:\Image2.png");
  image.Save(@"C:\Solution.bmp");

Having theses bits we can easily implement a decoder for the 1st challenge:

If we run the image and save the image into a file

using var image = ImageToBmp(@"C:\Image2.png");
  image.Save(@"C:\Solution.bmp");

Answer:

Having these bits we can easily implement a decoder for the 1st challenge:

If we run the routine and save the image into a file

   // Put the right file name here
using var image = ImageToBmp(@"C:\Image2.png");
  image.Save(@"C:\Solution.bmp");
deleted 3 characters in body; added 7 characters in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232
Loading
added 96 characters in body; added 4 characters in body; added 11 characters in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232
Loading
added 36 characters in body; added 10 characters in body; deleted 10 characters in body
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232
Loading
Source Link
Dmitrii Bychenko
  • 187.7k
  • 20
  • 179
  • 232
Loading