可以将可绘制的XmlSerializer xmlns文件转换为GIF或PNG吗? [英] can one convert drawable XmlSerializer xmlns file into GIF or PNG?

查看:77
本文介绍了可以将可绘制的XmlSerializer xmlns文件转换为GIF或PNG吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此文件在VB.NET中绘制,输入输出由XmlSerializer提供。

因此,简单的输出文件如下所示:


<?xml版本= QUOT; 1.0" encoding =" utf-8"?>

< DrawablePicture xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd =" http://www.w3.org/2001/XMLSchema" BackColor =" -1250856">

< DrawableRectangle LineWidth =" 2" X1 =" 377" Y1 =" 88" X2 = QUOT; 323" Y2 =" 130"

ForeColor =" -16777216"背景色= QUOT; -1" />

< / DrawablePicture>

我想通过网页显示它,但在我需要转换

之前它进入GIF ,PNG或任何网络图像可读文件。


有人可以对这个问题有所了解吗?你怎么能实现这个目标?

非常感谢你!

this file is drawn in VB.NET and input output goes by XmlSerializer.
Therefore, simple output file looks like:

<?xml version="1.0" encoding="utf-8"?>
<DrawablePicture xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" BackColor="-1250856">
<DrawableRectangle LineWidth="2" X1="377" Y1="88" X2="323" Y2="130"
ForeColor="-16777216" BackColor="-1" />
</DrawablePicture>
I would like to show it through webpage, but before I need to convert
it into GIF, PNG or any web-image readable file.

Can somebody please put some light on this issue? How would you
achieve that?
Thank you so much!

推荐答案




" Joe" < jo ***** @tlen.plwrote in message

news:f4 ************************* ********* @ m44g2000 hsc.googlegroups.com ...


"Joe" <jo*****@tlen.plwrote in message
news:f4**********************************@m44g2000 hsc.googlegroups.com...

此文件在VB.NET中绘制,输入输出由XmlSerializer提供。

因此,简单的输出文件如下所示:


<?xml version =" 1.0" encoding =" utf-8"?>

< DrawablePicture xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd =" http://www.w3.org/2001/XMLSchema" BackColor =" -1250856">

< DrawableRectangle LineWidth =" 2" X1 =" 377" Y1 =" 88" X2 = QUOT; 323" Y2 =" 130"

ForeColor =" -16777216"背景色= QUOT; -1" />

< / DrawablePicture>


我想通过网页显示它,但在我需要转换之前

进入GIF,PNG或任何网络图像可读文件。


有人可以对这个问题有所了解吗?你怎么能实现这个目标?


非常感谢你!
this file is drawn in VB.NET and input output goes by XmlSerializer.
Therefore, simple output file looks like:

<?xml version="1.0" encoding="utf-8"?>
<DrawablePicture xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" BackColor="-1250856">
<DrawableRectangle LineWidth="2" X1="377" Y1="88" X2="323" Y2="130"
ForeColor="-16777216" BackColor="-1" />
</DrawablePicture>
I would like to show it through webpage, but before I need to convert
it into GIF, PNG or any web-image readable file.

Can somebody please put some light on this issue? How would you
achieve that?
Thank you so much!



如果你可以创建一个图像,你不必创建一个文件来在网页上显示

信息。 />

您想要做的是以下内容:


1.在您的网站上创建一个新的aspx页面

2 。对于需要您图像的任何页面上的URL,将其设置为新的

创建aspx页面。然后使用QueryString,您可以将信息传递到页面

,它将用于创建图像。然后,您将写入Response

对象的图像。这将允许您在

页面上动态创建图像,而无需实际创建图像文件。


我有一个例子。我有一个按钮,我用它作为点唱机按钮。

而不是为每个轨道号创建不同的按钮。我使用按钮的背景简单地创建

a位图,然后将轨道号

强加为文本。


示例:


选项严格开启

选项明确开启


进口系统

进口系统。绘图

进口System.Drawing.Imaging

进口System.IO

进口MusicSiteControls


部分类DynamicImage

继承System.Web.UI.Page


Public Const imText As String =" ImageText"

Public Const imFolder As String =" ImageFolder"

受保护的子Page_Load(ByVal sender As Object,ByVal e As

System.EventArgs)处理Me.Load

Dim imageFolder As String

Dim imageText As String

Dim bm As Bitmap

Dim ms As MemoryStream


imageFolder = Request.QueryString(imFolder)

imageText = Request.QueryString(imText)


如果imageFolder什么都没有那么

bm = makeImage(imageText)

否则

bm = makeImage(imageFolder,imageText)

结束如果


如果bm什么都没有那么

bm =新位图(Server.MapPath(&〜/ Images / no-file-) 32x32.png"))

结束如果


ms =新的MemoryStream

bm.Save(ms,ImageFormat.Jpeg)

Response.ContentType =" image / jgp"

Response.BinaryWrite(ms.ToArray())

End Sub


私有函数makeImage(ByVal imagetext As String)As Bitmap

Dim bm As Bitmap

Dim g As Graphics

Dim bfont As Font


Dim tsize As SizeF

''Dim imageHeight As Integer

''Dim imageWidth As Integer


bfont =新字体(Trebuchet MS,14)

bm =新位图(Server.MapPath("〜/ Images) /TrackBackground.png"))


g = Graphics.FromImage(bm)

tsize = g.MeasureString(imagetext,bfont)


Dim tx As Single

Dim ty As Single


tx =(bm.Width - tsize.Width)/ 2

ty =(bm.Height - tsize.Height)/ 2


g。 DrawString(imagetext,bfont,New SolidBrush(Color.Black),tx,ty)

g.Dispose()


返回bm


结束函数


私函数makeImage(ByVal imageFolder As String,ByVal imagetext

As String)As Bitmap

Dim bm As Bitmap

''Dim g As Graphics

Dim bfont As Font


''Dim tsize As SizeF

''Dim imageHeight As Integer

''Dim imageWidth As Integer


bfont = New Font(" Trebuchet MS" ;,10)

Dim d作为新DAL

Dim folderName As String = d.GetImageFile(CInt(imageFolder))


Dim fn()As String = Directory.GetFiles(folderName," *。jpg")

如果fn.Length = 0然后

bm =没什么

返回bm

结束如果


bm =新位图(fn (0))


''Dim myImg As Bitmap

''Dim myCallback As System.Drawing.Image.GetThumbnailImageAbort

''昏暗的myPtr作为IntPtr

''myImg = DirectCast(bm.GetThumbnailImage(32,32,myCallback,myPtr),

位图)

''g = Graphics.FromImage(bm)

''g.DrawString(imagetext,bfont,New SolidBrush(Color.Black),2,2)

' 'g.Dispose()


返回bm

结束功能

结束班级

希望这个帮助

Lloyd Sheen

If you can create an image you don''t have to create a file to display the
info on a webpage.

What you want to do is the following:

1. Create a new aspx page in your website
2. For the URL on any page which needs your image set it to the newly
create aspx page. Using the QueryString you can then pass info to the page
which it will use to create an image. You will then write to the Response
object the image. This will allow you to dynamically create images on the
page without actually creating image files.

I have an example of this. I have a button which I use as a Jukebox button.
Rather than creating different ones for each "track number" I simple create
a bitmap using the background of the button and then impose the track number
as text.

Example:

Option Strict On
Option Explicit On

Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports MusicSiteControls

Partial Class DynamicImage
Inherits System.Web.UI.Page

Public Const imText As String = "ImageText"
Public Const imFolder As String = "ImageFolder"

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream

imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)

If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If

If bm Is Nothing Then
bm = New Bitmap(Server.MapPath("~/Images/no-file-32x32.png"))
End If

ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub

Private Function makeImage(ByVal imagetext As String) As Bitmap
Dim bm As Bitmap
Dim g As Graphics
Dim bfont As Font

Dim tsize As SizeF
''Dim imageHeight As Integer
''Dim imageWidth As Integer

bfont = New Font("Trebuchet MS", 14)

bm = New Bitmap(Server.MapPath("~/Images/TrackBackground.png"))

g = Graphics.FromImage(bm)
tsize = g.MeasureString(imagetext, bfont)

Dim tx As Single
Dim ty As Single

tx = (bm.Width - tsize.Width) / 2
ty = (bm.Height - tsize.Height) / 2

g.DrawString(imagetext, bfont, New SolidBrush(Color.Black), tx, ty)
g.Dispose()

Return bm

End Function

Private Function makeImage(ByVal imageFolder As String, ByVal imagetext
As String) As Bitmap
Dim bm As Bitmap
''Dim g As Graphics
Dim bfont As Font

''Dim tsize As SizeF
''Dim imageHeight As Integer
''Dim imageWidth As Integer

bfont = New Font("Trebuchet MS", 10)
Dim d As New DAL
Dim folderName As String = d.GetImageFile(CInt(imageFolder))

Dim fn() As String = Directory.GetFiles(folderName, "*.jpg")
If fn.Length = 0 Then
bm = Nothing
Return bm
End If

bm = New Bitmap(fn(0))

''Dim myImg As Bitmap
''Dim myCallback As System.Drawing.Image.GetThumbnailImageAbort
''Dim myPtr As IntPtr
''myImg = DirectCast(bm.GetThumbnailImage(32, 32, myCallback, myPtr),
Bitmap)
''g = Graphics.FromImage(bm)
''g.DrawString(imagetext, bfont, New SolidBrush(Color.Black), 2, 2)
''g.Dispose()

Return bm
End Function
End Class
Hope this helps
Lloyd Sheen


4月14日,1:28 * pm,Lloyd Sheen < a ... @ b.cwrote:
On Apr 14, 1:28*pm, "Lloyd Sheen" <a...@b.cwrote:

" Joe" < joe1 ... @tlen.plwrote in message

"Joe" <joe1...@tlen.plwrote in message



LLoyd,你的解决方案会解决,如果不是这样的话:1)我有一个

应用程序绘制(就像图表的东西),这个应用程序是完美的但是将结果转储到那个xmlns文件中...我只是简单地说

试图将其读回某些GIF文件....

LLoyd, your solution would work out, if not that: 1) I have an
application to draw (like a diagram thing), this application is
perfect but dumps result into that xmlns file... I am just simply
trying to read it back into some GIF file....




" Joe" < jo ***** @tlen.plwrote in message

news:d0 ************************* ********* @ y21g2000 hsf.googlegroups.com ...

4月14日下午1:28,Lloyd Sheen < a ... @ b.cwrote:

"Joe" <jo*****@tlen.plwrote in message
news:d0**********************************@y21g2000 hsf.googlegroups.com...
On Apr 14, 1:28 pm, "Lloyd Sheen" <a...@b.cwrote:

" Joe" < joe1 ... @tlen.plwrote in message

"Joe" <joe1...@tlen.plwrote in message



LLoyd,你的解决方案会解决,如果不是这样的话:1)我有一个

应用程序绘制(就像图表的东西),这个应用程序是完美的但是将结果转储到那个xmlns文件中...我只是简单地说

试图把它读回一些GIF文件....


这就是重点。您有一个文件,其中包含有关如何创建

图形的说明。所以aspx文件将文件名作为查询字符串,然后

创建图形(可能是一个gif)并将其传递给repsonse。在

现实中,这是用直接的gif URL完成的。


LS

LLoyd, your solution would work out, if not that: 1) I have an
application to draw (like a diagram thing), this application is
perfect but dumps result into that xmlns file... I am just simply
trying to read it back into some GIF file....

That is the point. You have a file with instuctions on how to create the
graphic. So the aspx file would take the filename as a querystring and then
create the graphic (could be a gif) and pass that to the repsonse. In
reality that is what is being done with a straight gif URL.

LS

这篇关于可以将可绘制的XmlSerializer xmlns文件转换为GIF或PNG吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆