.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Graphics Bitmaps & Rectangles

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Windows Application
I am trying to draw 2 bitmap images on top of each other. 1 is a background image that only changes occasionally and the other is a foreground image the moves around a lot. The foreground image is usually an ellipse. But when I show it I always end up with the corners of the constraining rectangle being shown! I have included some basic code that demonstrates what I mean. How can I show two bit maps with the top one only showing the exact shape I require (without gray corners). Also if I want to remove the foreground image from being seen do I need to redraw the entire background? or can I just redraw the bit where the foreground image was. or can I just hide the foreground image somehow? This maybe a basic question - Graphics are a new area to me! Many thanks in advance!   using   System; using   System.Collections.Generic; using   System.ComponentModel; using   System.Data; using   System.Drawing; using   System.Drawing.Drawing2D; using   System.Text; using   System.Windows.Forms; namespace   TEST200 {   public partial class Form1 : Form {   private Bitmap bmpBACKGROUND;   private Bitmap bmpFOREGROUND;   public Form1() { InitializeComponent(); }   private void Form1_Load(object sender, EventArgs e) { bmpBACKGROUND = new Bitmap(this.ClientRectangle.Width,

View Complete Post

More Related Resource Links

Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Foundations: Bitmaps and Pixel Bits


Charles Petzold takes an inside look at the flexible bitmap pixel formats offered by the retained-mode graphics features of Windows Presentation Foundation.

Charles Petzold

MSDN Magazine June 2008

Foundations: Vector Graphics and the WPF Shape Class


The System.Windows.Shapes namespace is Charles Petzold's namespace of choice for rendering two-dimensional vector graphics in WPF. Here he explains why.

Charles Petzold

MSDN Magazine March 2008

Smarter Art: Create Custom SmartArt Graphics For Use In The 2007 Office System


SmartArt incorporates a gallery of templates and predefined shapes that can quickly be inserted and configured in your Microsoft Office documents. Find out how.

Janet Schorr

MSDN Magazine February 2007

Graphics To Go: Make A Mobile Imaging App With The .NET Compact Framework 2.0


This article focuses on developing for Pocket PCs, a skill which can then be transferred to Smartphone application development.

Rob Pierry

MSDN Magazine December 2006

{ End Bracket }: Dirty Rectangles.


Here Jon Schwartz discusses a programming environment designed just for kids.

Jon Schwartz

MSDN Magazine September 2006

Dazzling Graphics: Top Ten UI Development Breakthroughs In Windows Presentation Foundation


The Windows Presentation Foundation provides new techniques for UI-based developing applications and makes better use of current hardware and technologies. In this article, Ian Griffiths and Chris Sells explain 10 of the most significant advances that make WPF superior to its Win32 predecessors.

Ian Griffiths and Chris Sells

MSDN Magazine January 2006

DirectX 9.0: Introducing the New Managed Direct3D Graphics API in the .NET Framework


DirectX 9.0 is the latest evolution of the Microsoft 3D graphics technology for Windows. Direct3D, a major component of the DirectX Graphics subsystem, has evolved so rapidly in the last few years that the underlying programming paradigm has changed quite a bit from its origin. This article introduces the fundamental concepts of the unmanaged Direct3D architecture and illustrates how the managed Direct3D layer abstracts the unmanaged layer. Also, the author describes the Geometry, Texture, Device, and other classes and uses code from the Samples SDK.

Yahya H. Mirza and Henry da Costa

MSDN Magazine July 2003

Vector Graphics: Build Flexible, Lightweight XML-Based Images for ASP.NET Using Scalable Vector Grap


Scalable Vector Graphics (SVG), a W3C graphics standard built around XML, is one of several vector graphics technologies that allows fast, lightweight drawings such as charts and graphs to be rendered on the fly in an appropriate viewer. There are many advantages to such vector graphics, including conservation of bandwidth and storage media, and flexibility. This article explains these benefits and shows you how to easily add powerful, dynamic, interactive visual elements to your Web applications.

Dennis Forbes

MSDN Magazine July 2003

ASP.NET: Create Snazzy Web Charts and Graphics On the Fly with the .NET Framework


Knowledge workers can understand data more effectively when raw numbers are presented in a graphical format. This is especially true when displaying database information on a Web page, where a simple chart can make the difference between a dry presentation and a vivid data source. In the past, creating dynamic, data-based charts on the fly in ASP required purchasing a third-party, image-generating COM component. Now with ASP.NET, developers can access the .NET Framework's drawing classes directly with C# to create dynamic images and charts.

Scott Mitchell

MSDN Magazine February 2002

Graphics: Manipulate Digital Images in Internet Explorer with the DirectX Transform SDK


The Microsoft DirectX Transform is a Microsoft DirectX media API that can be used to create animated effects as well as to create and edit digital images for Windows-based applications. Scripting and HTML can be used to display an existing transform on a Web page, and improved transform support in Microsoft Internet Explorer 5.5 makes it easy to use transforms. This article provides step-by-step instructions for writing a transform as an ATL project and shows an example of an image transform. C++ is used to instantiate, configure, and display transforms in this project.

Alex Lerner

MSDN Magazine March 2001

Tooltips for rectangles - there must be a standard way of doing this

I am implementing a graphic display that shows a bar with lighting changes over time.  Lights turn on and off according to a schedule. I already have code to show a series of different colored adjacent rectangles, with the color indicating the light level.  This is all drawn on a Graphics object, using FillRect. I would like to have a ToolTip for each rectangle, showing the lighting value (in Lux).  There seems to be no way to assign a ToolTip to a FillRect area, so I assume that I will have to dynamically create either Panel or PictureBox objects that show the colors.  Of course these will have to be Disposed when the window is redrawn. In some cases, I need to show a Hatch pattern (with HatchStyle) so it will not always be a solid color. Is there a simple and straightforward way to do this?  Is there another component that I am overlooking. I'm using VS2008 and C#, .NET 2.0. Thanks in advance, Michael Bate    

Creating an Array of Rectangles

I am trying to create an Array of Rectangles but can't quite get there as the syntax for the last line eludes me. Is there a way to do this  please?   Public aSquare(10) As Rectangle ---------------------- Dim noOfSquares(9) As Integer Dim strname(9) As String Dim ii As Integer For ii = 0 To 9 Strname(ii) = "mySquare" & noOfSquares(ii) Dim theName As String theName = strname(ii) 'Dim aSquare( ?? ) As New Rectangle Next

Compare 2 WPF bitmaps

Hi I have a question. I have an app which take some snapshots of the screen from time to time(as bitmaps)and compares the current screen with the previous one. This must work very fast and I was curios if I can use BitmapSource to achieve better performance(using GPU). The current solution compares pixel by pixel the 2 GDI+ bitmaps but it doesnt work as desired. Thank you

InteropBitmap, GDI bitmaps, and the alpha channel

Hey, After having successfully used InteropBitmap to render Windows Forms bitmaps in WPF scenes, I recently tried the same sort of thing using plain old GDI bitmaps, and I got surprising results.  So I am just doing something like: CBitmap gdiBitmap;gdiBitmap.CreateCompatibleBitmap( (CDC*) &dc, rClient.Width(), rClient.Height() );    and then I select it into a DC and make some GDI calls to fill it, draw a FrameRect, and draw some text.  After that, I do the normal dance to get the bitmap out of the DC, make a BitmapSource from it, and assign that to the Source property of the WPF Image in my scene: CBitmap * resbmp = dcOff.SelectObject( pOldBitmap );   HBITMAP hbmp = (HBITMAP) resbmp->GetSafeHandle();     BitmapSource ^bmpSource = CreateBitmapSourceFromHBitmap( (System::IntPtr) hbmp,       IntPtr::Zero, Int32Rect::Empty, BitmapSizeOptions::FromEmptyOptions() );   InteropBitmap ^ibmp = static_cast<InteropBitmap^>( bmpSource );     m_WPFImage->Source = ibmp;    When I do the above, the bitmap does not display *at all*.  After making some other calls to get the actual bits for the GDI bitmap, I can see that all of the alpha values are 0.  So what I'm getting is a bitmap that is completely transparent, and that is why InteropBitmap displays nothing.  The only way I have found to work around this is to pass the bitmap through GDI+ before creati

Using variables with a URL for external graphics in a report

I have a company logo that should appear in all the reports I create. I uploaded it to an Images folder on my SSRS server using Report Manager and then have modified my first report to refer to it using the External option then typing in the URL http://DC2VTSTSV032/reportserver/Images/CompanyLogo.png?%2fImages%2fCompanyLogo.PNG&rs:Command=GetResourceContents This all works fine and the graphic displays in layout and preview mode in the BI editor and also when I deploy the report on that server. My problem is, I would prefer that I use a variable instead of the server name DC2VTSTSV032. I have an environment variable that holds the server name on each server so I tried using ="http://"+%INGISSQLServer%+"/..." but it didn't like the reference to the environment so I tried using +Mid(GLOBAL!ReportServerURL,8,12)+. That didn't work. I then tried specifying the original url enclosed in quotes after an equals and that didn't work either! I'm guessing that there may be an issue with the way some of the special characters in my URL are treated when I use a literal string in quotes. The issue is that I'd like to be able to deploy the reports to both this dev server and the production one without making any changes. For the moment, the dev environment should show the new company logo and production should show the old logo so I don't want

Graphics.DrawImage(image, bounds) vs SetResolution

Hi    this is what I am undertanding.   Image object never store inch information, it is two-dimentional array of pixels, thus Image object don't have a DPI.    so I conclude that Image.SetResolution is actually changing the Image width and height with the current Graphics.InterpolationMode   from the naming of enumerations of Graphics.InterpolationMode I conclude it is a Re-Sampling algorithms.   thus   If I am drawing image in terms of inches then   Image.SetResoultion(Image.Width * someFactor/ DPI, ........);  Graphics.Draw(Image)   is equivalent to   Graphics.Draw(Image, Bounds in inch)   Can some one validate this?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend