?
Solved

how to draw bitmap above another bitmap ?

Posted on 2009-04-22
9
Medium Priority
?
1,777 Views
Last Modified: 2013-12-17
hi,
I have original bitmap loaded from bmp file, and I have another small (looks thumbnail) bitmap also loaded from file,
Now I want to draw (overwrite) this small thumbnail bitmap on left-bottom position of the original bitmap,
so third bitmap will be generated from previous bitmaps where the small bitmap drawn over original bitmap on the left-bottom position.
0
Comment
Question by:Ameerh24
  • 4
  • 2
  • 2
8 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 24202543
This should do it:
  Image bmp = Bitmap.FromFile("C:\\large.bmp");        // load large image
  Image thumb = Bitmap.FromFile("C:\\small.bmp");      // load thumbnail image
 
  Image target = (Image)bmp.Clone();                   // create destination image as clone of large
  Graphics gc = Graphics.FromImage(target);            // create graphics object for drawing
 
  Point drawAt = new Point(0, target.Height - thumb.Height);     // calculate lower left position
  gc.DrawImageUnscaled(thumb, drawAt);                           // draw thumbnail over large image
  gc.Save();                                                     // save the composite image

Open in new window

0
 

Author Comment

by:Ameerh24
ID: 24203121
thanks carl_tawn,
this works but there a matter of performance from your snippet code.
when I tried your code in a live video stream of images, it makes the stream slow because your code is slow, is there any solution ?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 24203251
What exactly is it that you are doing with the generated image?
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:Ameerh24
ID: 24203572
I have a usb camera that produces 15 frames (bitmaps) per second
I want to place a sort of thumbnail on that live video stream

I tried out your code, yes it places the thumbnail into each bitmap, but this makes the video very slow (jitter)
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24222864
For this kind of functionality, you would need to work with DirectX because it requires a lot of processing and the best place to do this processing is the Graphics Card.
How did you implement the suggested code? Can you show us the snippet?
0
 

Author Comment

by:Ameerh24
ID: 24285584
hi,
I am using a DLL of IpCam that capturing 15 frames per second
this is done in a separate thread in my solution when I tried carl_tawn on my solution the stream becoming very slow (but it works fine for single image)

some of my friends told me that I have to do it in c++ way using unsafe keyword
can some body help me with a code snippet ?
0
 

Author Comment

by:Ameerh24
ID: 24302194
please help me to answer the question
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 24302397
As i said, this being a very CPU intensive operation, you would need to write highly optimized code. You may need to use the DirectX api. The code given above should work for a few frames but executing this code 15 times a second is highly inefficient.
Check the following links

http://www.downloadthat.com/windows/Programming/Components---Libraries/DirectShow-Overlay-Filter_download.html

http://www.codeguru.com/cpp/g-m/directx/article.php/c1229

http://www.medialooks.com/products/directshow_filters/text_n_graphics_overlay.html

http://www.download3000.com/download_41760.html

http://www.eggheadcafe.com/software/aspnet/32121970/placing-text-overlay-on-d.aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question