473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Saving PointF data in MSAccess

VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e. to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.
Jun 18 '06 #1
5 1885
How about using a binarywriter to write the values to a memorystream,
get the byte array from the stream and use the Convert.ToBase64String
method to turn it into a string?

Keith G wrote:
VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e. to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.

Jun 18 '06 #2
Keith,

In addition to Goran.

http://www.vb-tips.com/default.aspx?...7-e68d238952a5

I hope this helps,

Cor

"Keith G" <Ke****@discussions.microsoft.com> schreef in bericht
news:6C**********************************@microsof t.com...
VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e.
to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.

Jun 19 '06 #3
Thanks Cor and Göran

I can see how the image data is converted into the Byte Array (and back)
from the code example. Which is very neat.
However, and this is the bit I'm struggling with, how do I save a
GraphicsPath to a MemoryStream?
Göran is suggesting using the BinaryWriter but how do I do that from a
PointF array?

The save and retrieve process to/from the database would therefore be:
SAVE
[GraphicsPath]->[BinaryWriter?]->[MemoryStream]->[Byte
Array]->[ToBase64String]
RETRIEVE
[FromBase64String]->[Byte
Array]->[MemoryStream]->[BinaryReader?]->[GraphicsPath]

"Cor Ligthert [MVP]" wrote:
Keith,

In addition to Goran.

http://www.vb-tips.com/default.aspx?...7-e68d238952a5

I hope this helps,

Cor

"Keith G" <Ke****@discussions.microsoft.com> schreef in bericht
news:6C**********************************@microsof t.com...
VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e.
to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.


Jun 21 '06 #4
The PointsF struct contains two float values; X and Y. Loop through the
array of PointFs and write each pair of values to the BinaryWriter.

To recreate the array you get two float values from the BinaryReader to
create each PointF struct.

As each float value is four bytes you can calculate the length of the
PointF array by taking the length of the byte array and divide by eight.
Keith G wrote:
Thanks Cor and Göran

I can see how the image data is converted into the Byte Array (and back)
from the code example. Which is very neat.
However, and this is the bit I'm struggling with, how do I save a
GraphicsPath to a MemoryStream?
Göran is suggesting using the BinaryWriter but how do I do that from a
PointF array?

The save and retrieve process to/from the database would therefore be:
SAVE
[GraphicsPath]->[BinaryWriter?]->[MemoryStream]->[Byte
Array]->[ToBase64String]
RETRIEVE
[FromBase64String]->[Byte
Array]->[MemoryStream]->[BinaryReader?]->[GraphicsPath]

"Cor Ligthert [MVP]" wrote:
Keith,

In addition to Goran.

http://www.vb-tips.com/default.aspx?...7-e68d238952a5

I hope this helps,

Cor

"Keith G" <Ke****@discussions.microsoft.com> schreef in bericht
news:6C**********************************@microsof t.com...
VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e.
to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.


Jun 22 '06 #5
I have now successfully saved and retrieved the PointF data using the
BinaryWriter and BinaryReader.

For anybody else that might be interested the read and write loops
respectively have ended up like this:
----------
For i = PointArray(intZoneCount).GetLowerBound(0) To
PointArray(intZoneCount).GetUpperBound(0)
pt = PointArray(intZoneCount).GetValue(i)
bt = pt.X
bw.Write(bt)
bt = pt.Y
bw.Write(bt)
Next

For i As Integer = 0 To intPts
intX = br.ReadSingle
intY = br.ReadSingle
PointArray(intZoneCount).SetValue(New PointF(intX, intY), i)
Next
---------------

Thanks to Göran and Cor for your help.

Regards..
"Göran Andersson" wrote:
The PointsF struct contains two float values; X and Y. Loop through the
array of PointFs and write each pair of values to the BinaryWriter.

To recreate the array you get two float values from the BinaryReader to
create each PointF struct.

As each float value is four bytes you can calculate the length of the
PointF array by taking the length of the byte array and divide by eight.
Keith G wrote:
Thanks Cor and Göran

I can see how the image data is converted into the Byte Array (and back)
from the code example. Which is very neat.
However, and this is the bit I'm struggling with, how do I save a
GraphicsPath to a MemoryStream?
Göran is suggesting using the BinaryWriter but how do I do that from a
PointF array?

The save and retrieve process to/from the database would therefore be:
SAVE
[GraphicsPath]->[BinaryWriter?]->[MemoryStream]->[Byte
Array]->[ToBase64String]
RETRIEVE
[FromBase64String]->[Byte
Array]->[MemoryStream]->[BinaryReader?]->[GraphicsPath]

"Cor Ligthert [MVP]" wrote:
Keith,

In addition to Goran.

http://www.vb-tips.com/default.aspx?...7-e68d238952a5

I hope this helps,

Cor

"Keith G" <Ke****@discussions.microsoft.com> schreef in bericht
news:6C**********************************@microsof t.com...
VS2003 using VB.Net

I want to be able to save drawing path data in a database.
If I store the Points array for each GraphicsPath I can then reproduce (in
this case) filled polygons at run time. The user will create the polygons
initially.
The number of points in the polygons will vary so I only want to save this
data in one field (rectangles would have been a lot easier).

The only way I can think of doing this is by saving the points as a string
in a Memo field; looping through all the points in the Array and using
GetValue to add the points to the string e.g.:
{x=369, y=89}{x=500, y=200}{x=700, y=300}

To retrieve the polygon at the next run time then seems a bit messy i.e.
to
extract the points from the string and get them in the PointF format e.g.:
PointArray(intZoneCount).SetValue(New PointF(369, 89), 0) (would be the
first point)
I can see how this can be done and I'm sure it will work but can anyone
suggest a better way? or am I missing something blindingly obvious!

Thanks in advance.

Jun 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Devin Dow | last post by:
Framework Classes, like Point, PointF, Rectangle, etc., show nice info when you float over them or do a watch. For example, floating over a PointF shows "{X=1.0 Y=2.0}" But my classes only show...
10
by: Andrea M. Segovia | last post by:
Hello, I am a newbie to Oracle databases.... We have a visualization front-end tool connected to an Oracle back-end database on a Tru64 UNIX server. We also have clients with MS access...
9
by: Tom Weston | last post by:
Help I have 4 databases containing different data relating to safety, not written by me. It is not possible to merge the databases into one large data base. I would like to create a user interface...
6
by: Hemil | last post by:
Hello Friends, I require to load data from an xml file into one of my linked access tables. The structure of this table is something like: ID/XmlTag/Value I guess I need to read the XML...
1
by: MadCrazyNewbie | last post by:
Hey Group, I wounder if somebody could possibly help me a little? Is it possible to store XLS and DOC files into a MSaccess Database, or SQL Database? If so anybody got any links or tips? ...
1
by: Paul | last post by:
PointF is used as part of the fillpolygon method. The code below is looping through the array count and then creating a new point based on 2 array list values. One array has the x data points and...
0
by: KNN | last post by:
I am running the frond end Access 2003 application under Citrix. There is no problem running the appcilation in this mode. When I try to export a report and select a drive on the citrix server, ...
0
by: Shyam Barnwal | last post by:
Hi All, I am working on winamp general purpose pluggin "gen_whatsplaying " project downloaded from the site www.schaffrath.net I compiled and build the project successfully using platform SDK...
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.