can one convert drawable XmlSerializer xmlns file into GIF or PNG?

J

Joe

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!
 
L

Lloyd Sheen

Joe said:
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!

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
 
J

Joe

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....
 
L

Lloyd Sheen

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
 
J

Joe

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

ok, so I need a script that will "read" xmlns file and create an image
file according to content.
Rather than having every function being rewritten by myself, I am
looking for a library (script) that already does that....
 
L

Lloyd Sheen

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

ok, so I need a script that will "read" xmlns file and create an image
file according to content.
Rather than having every function being rewritten by myself, I am
looking for a library (script) that already does that....


Where do you get these files from? It looks like (but I know it isn't) a
metafile with commands used to draw images. Googling I find a Scilab
graphics class. Does your app have a reference to this. If so I would
think there might be methods in the class library which would take the info
and draw a graphic.

And not to be a traffic cop here but deleting part of the thread makes
responding difficult for me and most likely impossible for others who join
late.

LS
 
J

Joe

ok, so I need a script that will "read" xmlns file and create an image
file according to content.
Rather than having every function being rewritten by myself, I am
looking for a library (script) that already does that....

Where do you get these files from?  It looks like (but I know it isn't) a
metafile with commands used to draw images.  Googling I find a Scilab
graphics class.  Does your app have a reference to this.  If so I would
think there might be methods in the class library which would take the info
and draw a graphic.

And not to be a traffic cop here but deleting part of the thread makes
responding difficult for me and most likely impossible for others who join
late.

LS- Hide quoted text -

- Show quoted text -

I am sorry for not providing you more info. I need a simple "map"
drawing functionality and this resource is a perfect solution:
http://www.vb-helper.com/howto_net_drawing_framework.html

the only problem is that this outputs PIC XMLserialize file instead of
a GIF/PNG file which I am trying to achieve...


Thank you.
 
L

Lloyd Sheen

ok, so I need a script that will "read" xmlns file and create an image
file according to content.
Rather than having every function being rewritten by myself, I am
looking for a library (script) that already does that....

Where do you get these files from? It looks like (but I know it isn't) a
metafile with commands used to draw images. Googling I find a Scilab
graphics class. Does your app have a reference to this. If so I would
think there might be methods in the class library which would take the
info
and draw a graphic.

And not to be a traffic cop here but deleting part of the thread makes
responding difficult for me and most likely impossible for others who join
late.

LS- Hide quoted text -

- Show quoted text -

I am sorry for not providing you more info. I need a simple "map"
drawing functionality and this resource is a perfect solution:
http://www.vb-helper.com/howto_net_drawing_framework.html

the only problem is that this outputs PIC XMLserialize file instead of
a GIF/PNG file which I am trying to achieve...


Thank you.


Have you downloaded the framework that is pointed at in the web page? If so
is there a method to draw the graphics? The first method on the page
mentions a Draw routine which takes a Graphics object as a parameter. In
the sample I provided you will notice that it uses a Graphics object to draw
on.

A combination of the two should do the job.

Lloyd Sheen
 
J

Joe

I am sorry for not providing you more info. I need a simple "map"
drawing functionality and this resource is a perfect solution:http://www.vb-helper.com/howto_net_drawing_framework.html

the only problem is that this outputs PIC XMLserialize file instead of
a GIF/PNG file which I am trying to achieve...

Thank you.

Have you downloaded the framework that is pointed at in the web page?  If so
is there a method to draw the graphics?  The first method on the page
mentions a Draw routine  which takes a Graphics object as a parameter.  In
the sample I provided you will notice that it uses a Graphics object to draw
on.

A combination of the two should do the job.

Lloyd Sheen- Hide quoted text -

- Show quoted text -

they would... but it does not use Graphics object... it use
XMLSerialize to write into file and back from it only coordinance of
each objects... it is not a picture, it is a group of XML serialized
shapes... :(
 
L

Lloyd Sheen

I am sorry for not providing you more info. I need a simple "map"
drawing functionality and this resource is a perfect
solution:http://www.vb-helper.com/howto_net_drawing_framework.html

the only problem is that this outputs PIC XMLserialize file instead of
a GIF/PNG file which I am trying to achieve...

Thank you.

Have you downloaded the framework that is pointed at in the web page? If
so
is there a method to draw the graphics? The first method on the page
mentions a Draw routine which takes a Graphics object as a parameter. In
the sample I provided you will notice that it uses a Graphics object to
draw
on.

A combination of the two should do the job.

Lloyd Sheen- Hide quoted text -

- Show quoted text -

they would... but it does not use Graphics object... it use
XMLSerialize to write into file and back from it only coordinance of
each objects... it is not a picture, it is a group of XML serialized
shapes... :(


Is there no implementation of the Draw method in the framework?
 
J

Joe

they would... but it does not use Graphics object... it use
XMLSerialize to write into file and back from it only coordinance of
each objects... it is not a picture, it is a group of XML serialized
shapes... :(

Is there no implementation of the Draw method in the framework?- Hide quoted text -

- Show quoted text -

unfortunately no :(
 
L

Lloyd Sheen

they would... but it does not use Graphics object... it use
XMLSerialize to write into file and back from it only coordinance of
each objects... it is not a picture, it is a group of XML serialized
shapes... :(

Is there no implementation of the Draw method in the framework?- Hide
quoted text -

- Show quoted text -

unfortunately no :(

Since I don't know what you want to do with those files I guess this is as
far as I can take you.

LS
 
J

Joe

unfortunately no :(

Since I don't know what you want to do with those files I guess this is as
far as I can take you.

LS- Hide quoted text -

- Show quoted text -

that's simple I just want to save them into GIF format, but I need a
little help showing me how to extract photo data from that
XMLSerialize document...
hope that make sense...
 
L

Lloyd Sheen

unfortunately no :(

Since I don't know what you want to do with those files I guess this is as
far as I can take you.

LS- Hide quoted text -

- Show quoted text -

that's simple I just want to save them into GIF format, but I need a
little help showing me how to extract photo data from that
XMLSerialize document...
hope that make sense...


From what I see there is only a rectangle. It seems to have the coordinates
of the upper left corner and bottom right corner, along with the width of
the line to be drawn and various colour information. I would hope that the
framework you are using has documentation for the various pieces.

What you would get is a rectangle which I think by itsself is just that.

You have two tasks. First to extract the info and second to draw.

I suggest you read up on XML first. That will extract your info. Without
knowing what the schema of the XML is I can't help much here but there is
lots of docs on using XML in Dot.Net.

Then you need to investigate the drawing classes. If all you are doing is
drawing rectangles that is fairly simple.

LS
 
J

Joe

that's simple I just want to save them into GIF format, but I need a
little help showing me how to extract photo data from that
XMLSerialize document...
hope that make sense...

From what I see there is only a rectangle.  It seems to have the coordinates
of the upper left corner and bottom right corner, along with the width of
the line to be drawn and various colour information.  I would hope that the
framework you are using has documentation for the various pieces.

What you would get is a rectangle which I think by itsself is just that.

You have two tasks.  First to extract the info and second to draw.

I suggest you read up on XML first.  That will extract your info.  Without
knowing what the schema of the XML is I can't help much here but there is
lots of docs on using XML in Dot.Net.

Then you need to investigate the drawing classes.  If all you are doing is
drawing rectangles that is fairly simple.

LS- Hide quoted text -

- Show quoted text -

yes you are right, there is about 10 different shapes.. I guess I will
hate to write my own function how to retreive each value and "redraw"
it again..
thank you for your feedback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top