1

我们有一些传统的硬件/软件可以通过 Matrox 卡将图形显示到电视上。图形是文件(bmp、tga)和文本元素的组合。图形的布局位于 XML 文件中。我正在尝试在一个窗口中渲染这些图形以进行预览,而无需访问特殊硬件。我正在使用基本的 .NET gfx 类:位图和图形。

问题是我无法获取 XML 文件中的坐标以匹配对象应在窗口中显示的位置。例如,XML 说在 13,159 处渲染“test.bmp”,但在示例图形中,它应该在 94、24 处。另一个是 XML 坐标是 232,-48,但实际坐标是 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
4

0 回答 0