如何从 MapXtreme 样式制作位图
我已在 MapXtreme 论坛上发布了这个问题,但由于没有人在那里回答问题,我希望这里有人对此产品有一些经验(mapxtreme 是由制作 MapInfo 的人制作的 GIS SDK),
我正在开发 MapXtreme 桌面应用程序,并且我们需要我们的特征样式的位图
我尝试了两种方法,但我得到的只是带有深色X的灰色位图。
这是我使用的两种方法都在代码中的代码,但其中一种被注释掉了:
public static Bitmap GetStyleBitmap(Style style)
{
var bm = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var rect = new System.Drawing.Rectangle(0, 0, 16, 16);
var ss = new StyleSample();
ss.Bounds = rect;
if (style is CompositeStyle)
{
ss.ApplyAreaStyle(((CompositeStyle)style).AreaStyle);
ss.ApplyLineStyle(((CompositeStyle)style).LineStyle);
}
if (style is AreaStyle)
{
ss.ApplyAreaStyle((AreaStyle)style);
}
if (style is SimpleLineStyle)
{
ss.ApplyLineStyle((SimpleLineStyle)style);
}
//using MapExport
var me = new MapExport(ss.Map);
var image = me.Export();
return new Bitmap(image);
//using StyleSample.DrawToBitmap
//ss.DrawToBitmap(bm, rect);
//return bm;
}
TIA
I have posted this question on The MapXtreme forum but since nobody ever answers questions there I am hoping someone here has some experience with this product (mapxtreme is a GIS SDK made by the people who make MapInfo)
I am working on a MapXtreme Desktop app and we need bitmaps of our features styles
I have tried two ways but all I get is a grey bitmap with a dark X.
here is the code I have used both ways are in the code but one is commented out:
public static Bitmap GetStyleBitmap(Style style)
{
var bm = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
var rect = new System.Drawing.Rectangle(0, 0, 16, 16);
var ss = new StyleSample();
ss.Bounds = rect;
if (style is CompositeStyle)
{
ss.ApplyAreaStyle(((CompositeStyle)style).AreaStyle);
ss.ApplyLineStyle(((CompositeStyle)style).LineStyle);
}
if (style is AreaStyle)
{
ss.ApplyAreaStyle((AreaStyle)style);
}
if (style is SimpleLineStyle)
{
ss.ApplyLineStyle((SimpleLineStyle)style);
}
//using MapExport
var me = new MapExport(ss.Map);
var image = me.Export();
return new Bitmap(image);
//using StyleSample.DrawToBitmap
//ss.DrawToBitmap(bm, rect);
//return bm;
}
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在等待答案 - 并尝试了无数其他方法 - 都无济于事后,我决定“手动”完成这一切,即我只是在样式对象中查看它的颜色并绘制适合图层类型的位图(线或多边形)。
它不能处理所有情况,也不能处理线条样式或内部颜色,但它目前可以满足我的目的。
这是执行此操作的代码。
After waiting for an answer - and trying countless other ways - all to no avail, I decided on doing it all 'by hand' ie I simply look in the style object get the colour of it and draw a bitmap appropriate for the layer type (line or polygon).
It doesnt handle every case and also doesnt handle line styles or interior colours but it serves my purposes for now.
here is the code that does it.
第一个代码已经几乎可以工作了。 我只是稍微调整了一下就修复了它。
我已经测试了它的复合样式,其中包含 simplevectorpointstyle。
The first code already almost worked. I just tweaked it a little bit to fix it.
I have tested it for a composite style that contains a simplevectorpointstyle in it.