图形协调问题

时间:2012-11-06 15:11:18

标签: .net graphics coordinates

我们有一些传统的硬件/软件可以通过Matrox卡向电视显示图形。图形是文件(bmp,tga)和文本元素的组合。图形的布局在XML文件中。我试图在一个窗口中呈现这些图形,以便在不访问特殊硬件的情况下进行预览。我正在使用基本的.NET gfx类:Bitmap和Graphics。

问题是我无法获取XML文件中的坐标以匹配窗口中应显示对象的位置。例如,XML表示在13,159处呈现“test.bmp”,但在示例图形中它应该是94,24。另一个是XML co-ord是232,-48但真正的co-ord是530,138。

我知道这不是很多信息,但如果有人对如何映射这些坐标有任何意见,我会很感激。完整的图形大小为720x486。

要合成我做的图像:

// Target bitmap all others get composited into
Bitmap bmp = new Bitmap(720, 486);
Graphics g = Graphics.FromImage(bmp);
// Load a new bitmap
string file_name;         // Path to image from XML file
float x, y;               // Position. Pulled from the XML
float w, h;               // Width and height. Also from the XML. Seems always to be Bitmap w,h
float scale_x, scale_y;   // Scaling. Also from the XML
// Parse XML file....
Bitmap bmp_new = new Bitmap(file_name);
RectangleF r = new RectangleF(x, y, w * scale_x, h * scale_y);
g.DrawImage(bmp_new, r);
pixPreview.Image = bmp;    // PictureBox control for veiwing

0 个答案:

没有答案
相关问题