• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 603
  • Last Modified:

Flatten image using c#

I have an image that I have to flatten using c#.  How can I do it Is it possible?  The image is a bitmap.
0
dbdp
Asked:
dbdp
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
I need to make sure what you mean by "flatten".

Bob
0
 
dbdpAuthor Commented:
I will try and explain - basically I am creating a barcode by "drawing"  the lines - when I save this barcode as a bitmap - the only thing being saved are the lines - i.e. it is not saved against a white background.  I basically need to add the white background.
0
 
Babycorn-StarfishCommented:
Hi,

what colour is the background? black?

BCS
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Babycorn-StarfishCommented:
Hi again,

how are you setting up your image? Have you tried firstly drawing a white rectangle the size of the image and then drawing onto the now white image?
0
 
dbdpAuthor Commented:
Well, transparent - in actual fact there isn't a background and that's my problem
0
 
Babycorn-StarfishCommented:
My crude example:

            Bitmap b = new Bitmap(100, 100);
            Graphics g = Graphics.FromImage(b);
            g.FillRectangle(Brushes.White, new Rectangle(0, 0, b.Width, b.Height));
            g.DrawLine(Pens.Black, new Point(10, 0), new Point(10, 100));
            g.DrawLine(Pens.Black, new Point(15, 0), new Point(15, 100));
            g.DrawLine(Pens.Black, new Point(50, 0), new Point(50, 100));
            g.DrawLine(Pens.Black, new Point(55, 0), new Point(55, 100));
            g.DrawLine(Pens.Black, new Point(80, 0), new Point(80, 100));

it'd be better to setup the Bitmap a bit more precisely, setting pixel format etc.
0
 
dbdpAuthor Commented:
Full Marks to you my friend

Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now