Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.

I'm programming a tool that given a section (eg 16 x 16), drawings of characters from an image, but I can not, because everything that I found on the Internet, draw the form. Can anyone help me?
This is the code that I did, but that does not work.
Thanks in advance:)

C#
private void btnWrite_Click(object sender, EventArgs e)
        {
            Image img = new Bitmap(ofd.OpenFile());

            Rectangle section = new Rectangle();

            section.Height = (int)gridHeigth.Value;
            section.Width = (int)gridWidth.Value;
            section.X = 0;
            section.Y = 0;
            Graphics grp = CreateGraphics();
            grp.DrawImage(img, section);
        }
Posted

1 solution

Oh (sigh)… I discovered yet another case of an attempt to misuse of PictureBox. Let me explain that. This control is designed for somebody who does not want to deal with any graphics at all. Something simple and simpler. Nothing dynamic, animated, combined, manipulated. Pure static image, maybe sometimes replaced, but not often.

By the reason of deep confusion about graphics, many try to do a lot more, which is possible but just silly. This control does not help it, only presents a hassle.

So, what do to? Something way more simple:
How do I clear a panel from old drawing[^].

If you picture is static, it's even simpler than that. Do invalidation, no double buffering. But you can do moving images, animation, saving to file or loading from files and a lot more.

—SA
 
Share this answer
 
Comments
Dr.Walt Fair, PE 13-Sep-11 22:06pm    
Well stated.
Sergey Alexandrovich Kryukov 13-Sep-11 22:15pm    
Thank you, Walt.
--SA
Prerak Patel 14-Sep-11 2:37am    
Comment from OP:
Thanks for comment.

I've only to do this:

I write a text in textBox1, and when i press the button, it "translate" from text to image fonts, where i in source i give to all letter a section of an image.

Now i try, thanks
Sergey Alexandrovich Kryukov 14-Sep-11 9:40am    
Nevertheless, please follow my recipe (ask you have a question).
Good luck,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900