Solved

Need help with matrix in Graphic.  C#

Posted on 2007-03-28
1
180 Views
Last Modified: 2013-12-17
I found this code online that can help me fit my image in my panel as best as possible.

double largestRatio = Math.Max((double)image.Width / this.ImageDrwPanel.Width, (double)image.Height / this.ImageDrwPanel.Height);
            float posX = (float)(this.ImageDrwPanel.Width * largestRatio / 2 - image.Width / 2);
            float posY = (float)(this.ImageDrwPanel.Height * largestRatio / 2 - image.Height / 2);
            mx = new Matrix(1.0f / (float)largestRatio, 0, 0, 1.0f / (float)largestRatio, 0, 0);
            mx.Translate(posX, posY);
            this.statusBarPanelZoom.Text = "Best Fit";
            memGraphic.Transform = mx;

This code work perfectly and it fit the image in my panel as best as possible,  but I wanted to expand on this code and fill in the rest of the panel with a different color.  Such as red or yellow.  Can some experts tell me how can I fill in the rest of the background with another color?  I've been trying to generate another matrix to draw in my memGraphic, but I can't seem to make it working properly.  

PS

I overrided the OnPaintBackground method because I don't like the way it render the background and I wanted to generate the background manually.
0
Comment
Question by:raw_enha
1 Comment
 
LVL 16

Accepted Solution

by:
AlexNek earned 500 total points
Comment Utility
Background color is not related with transformation matrix
http://www.codeproject.com/csharp/matrix_transformation.asp
You need to fill the panel before drawing the image.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now