473,499 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

transformation matrix; graphics

Hello,

how can I make the transformation matrix?

Zero point
Left top
Left bottom
Right top
Right bottom

I have a list of points
private void Form1_Load(object sender, EventArgs e)
{
ListCodes = new List<CODES>();
CODES obj;

int boardnumber = 0;
for (int j = 0; j < 4; j++)
{
for (int i = 0; i < 5; i++)
{
boardnumber++;
obj = new CODES();
obj.Init();
obj.X = obj.X + (j * 150);
obj.Y = obj.Y + (i * 70);
obj.BoardNumber = boardnumber;
ListCodes.Add(obj);
}
}
}

Regards Thomas

private void MapMillimetersToPixels(Graphics gfx, Rectangle
rectPixels, Rectangle rectMm)
{
Matrix matrix = new Matrix();
ScaleX = (float)rectPixels.Width / rectMm.Width;
ScaleY = (float)rectPixels.Height / rectMm.Height;
matrix.Scale(ScaleX, ScaleY);
matrix.Translate(rectPixels.Left - ScaleX * rectMm.Left,
rectPixels.Top - ScaleY * rectMm.Top);

gfx.Transform = matrix;
}

Oct 26 '07 #1
1 3838
In article
<11**********************@o3g2000hsb.googlegroups. com>Thomas Bauer
<ma******@arcor.dewrote:
Hello,
how can I make the transformation matrix?
Zero point
Left top
Left bottom
Right top
Right bottom
This is related to your other thread, I assume.

The key here is to set the appropriate rectMM before calling the
Map...() method.

For example:

bool fZeroLeft, fZeroTop;

where these two flags indicate which side of the rectangle is the
origin. If they are both set, the origin is the left and top, if
neither is set, the origin is the right and bottom, etc.

Then:

int mmWidth, mmHeight;
Rectangle rectMM;

You should already know the width and height of the device, of course.
Those values will be in the mmWidth and mmHeight variables. We will
initialize rectMM as appropriate:

rectMM = new Rect(
new Point(fZeroLeft ? 0 : -mmWidth,
fZeroTop ? 0: -mmHeight),
new Size(fZeroLeft ? mmWidth : -mmWidth,
fZeroTop ? mmHeight : -mmHeight));

Then if you pass that rectMM into the Map...() method, it should
configure the transformation matrix appropriately.

Granted, I haven't actually tested any of this. You may have to
adjust some of the code to get it to work exactly right. But this is
the basic theory.

Pete

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo

Oct 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
882
by: gazza67 | last post by:
Hi People, I have a graphics problem. I have a diagram that is stored with all of its X,Y coordinates having an origin of Bottom right corner, when I display the diagram I want it with the...
10
1809
by: Nevets Steprock | last post by:
I'm writing a web program where one of the sections is supposed to output a correlation matrix. The typical correlation matrix looks like this: ..23 ..34 .54 ..76 .44 .28 ..02 .77 ...
4
21256
by: Harry | last post by:
Hello, I am using a 2-dimensional matrix for image manipulation and recognition. The x-axes is image.width pixels long and the y-axes image.height. All fields have a RGB integer value. To store...
2
2673
by: Peter Proost | last post by:
Hi group, I got the following piece of code which draws a square with stars round it, now I want the stars to rotate round the square, I can do this with the mx.rotate and a timer and an...
3
6695
by: Eduard Witteveen | last post by:
Hello list, I have code the draw MyDrawingObject information on a System.Drawing.Graphics object. The code is more/less the following: I now want to rotate / mirror the object i draw. I've...
1
3056
by: Kamilche | last post by:
I have a need to tile a bitmap across an arbitrary quadrilateral, and apply perspective to it. The Python Imaging Library (PIL) has an undocumented function that might work, but I can't figure out...
232
13062
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
14
9087
by: Thomas Bauer | last post by:
Hello, I search a example like that. (1,0,0,1,4,5 ) -- moving (1,0,0,1,0,0 ) -- normal matrix (-1,0,0,1,0,0 ) -- Mirror Y-Axis (0,-1,0,1,0,0 ) -- Mirror X-Axis I caluculate all in mm.
7
2546
by: locy | last post by:
hello, i am have a little problem .how do i write a programm(Geometric Transformation) of linear Transformation in Translation,scalling and rotation
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.