Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string DLSB(Bitmap bmp)
- {
- string ExtractedText = "";
- List<int> IDBits = new List<int>();
- List<int> MsgBits = new List<int>();
- string ID = "";
- int MarqueSize = 0;
- bool IDFound = false;
- int ColorIndex = 0, Counter = 0, charValue = 0;
- for (int x = 0; x < bmp.Width; x++)
- {
- for (int y = 0; y < bmp.Height; y++)
- {
- Color pixel = bmp.GetPixel(x, y);
- for (int n = 0; n < 3; n++)
- {
- if (ColorIndex % 3 == 0)
- {
- charValue = charValue * 2 + pixel.R % 2;
- }
- else if (ColorIndex % 3 == 1)
- {
- charValue = charValue * 2 + pixel.G % 2;
- }
- else if (ColorIndex % 3 == 2)
- {
- charValue = charValue * 2 + pixel.B % 2;
- }
- ColorIndex++;
- Counter++;
- if (IDFound) MsgBits.Add(charValue % 2);
- else IDBits.Add(charValue % 2);
- if (Counter == 8)
- {
- if (!IDFound && charValue == 0)
- {
- IDFound = true;
- ID = BitToString(IDBits);
- MarqueSize = Convert.ToInt16(ID.Split('-')[2]) * 8;
- Console.WriteLine("ID Found : " + ID);
- }
- else if (IDFound && MsgBits.Count >= MarqueSize) goto ExtractionDone;
- charValue = 0;
- Counter = 0;
- }
- } // End For loop pixel colors
- } // end for y
- } // end for x
- ExtractionDone:
- Console.WriteLine("ExtractionDone");
- ExtractedText = BitToString(MsgBits);
- return ExtractedText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement