Solved

Need help with matrix in Graphic.  C#

Posted on 2007-03-28
1
182 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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