Solved

Need help with matrix in Graphic.  C#

Posted on 2007-03-28
1
181 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
ID: 18809889
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

19 Experts available now in Live!

Get 1:1 Help Now