Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
this is a work given to me by my company. i haveto decode a character given at a particular location on the screen how do i decode that
with regards
punnoose
Sounds like a test. You employers want to know if you have the knowledge to figure this out? In which case, you need to understand character encoding and image formats.
For eg. a way to add a character to a bitmap would be to replace a particular pixel value with the character's ascii value. In the picture, it would appear as a single wrong pixel, lost in a high-res image.
You could extract it by zooming in on the image (without anti-aliasing) until individual pixels are visible, then using a color picker tool.
A more common way is to xor the string, suitably padded, to the binary of the image. You extract the plaintext with xor and the unadulterated image.
It is also possible to create a bitmap of the character at a suitable resolution - then odd it to the bitmap image, then compress the image. Nasty as jpeg compression is lossy.
My point here is that there are lots of ways of getting text into another file (image file in this case). If you have not been told how, then you will have to use your native wit, and your knowledge of the resources available to the people who made the image, to figure it out.
Exactly - are we talking about a character drawn in the image at a particular x-y location - in that sence "embedded" or one of the other myriad methods available?
Please answer the questions in the previous responses.
If I use my previous example of adding a string to a bitmap - you will notice that the string is just a row of numbers, and so is the bitmap. In the bitmap, the numbers represent color values while in the string the numbers represent characters.
The exact meaning of the numbers depends on how the characters/colors are encoded. Maybe the colors are HSV, maybe the characters are utf8? Whatever.
Normally an image will have some metadata at the start - this will depend on the actual encoding of the image. Typically, the metadata will say how wide hde image is and what the color encoding is. If the metadata of the image occupies the first N bytes, and the string has S bytes, then you can substitute the bytes of the string for the bytes of thu image starting at byte N+1 and ending at N+S.
So, you need to study character and image encoding methods. You need to find the C++ instructions for manipulating binary files. Then you will have your solution.
Another alternative would be to write out your string as a bitmap - in a painting program, for eg. Then you can just xor the two bitmaps together.
Z = Img xor Str
In which case, you just need to know how to do an xor operation in C++
Good luck.
Last edited by Simon Bridge; 05-07-2008 at 01:45 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.