On Jun 10, 2006, at 4:50 PM, RBNUBE wrote:
I'm making a grid using a Canvas. The grid allows you to drop
multiple images on it that you have dragged from a ListBox. I need
to store the name of the picture, the top and left coordinates for
retrieval at some time in the future, even if the application has
been closed.
Any suggestions as to go about storing references multiple images
and their positions? Multiple arrays? Dictionaries? Any
suggestions would be appreciated.
Sounds like you are making a document format. I also think that you
would want to store other information such as picture order (back to
front), the actual FolderItem property (not just the name since that
might change), and possibly a mask for the picture as well.
Dealing with pictures is a big pain especially when they get deleted,
renamed or moved. If at all possible, it would probably be better to
store the entire picture in the document instead of trying to keep an
alias to the original file. Though this is what professional
programs do, it is a lot more work and may not be necessary for you.
So what I would do is create a new Class "ImageObj" with the
following properties:
X As Integer
Y As Integer
Height As Integer (Computed Property linked to Image.Height or 0)
Width As Integer (Computed Property linked to Image.Width or 0)
Name As String
Image As Picture
The ImageObj has at least three methods... a Constructor, an Import
and an Export function. The Constructor is more of a convenience
function and just refers to the Import function with the "ImageObj"
data. For storing/retrieving the picture data, I would use the
PNGUtilities to store the picture into string data. Then you just
prepend the X and Y values and the length of the PNG data to have the
picture saved to disk.
X As Integer (4 Bytes)
Y As Integer (4 Bytes)
Length As Integer (4 Bytes)... length of PNG data ONLY
PNGData As String (? Bytes)
For your canvas, you would have an array of these "ImageObj" to keep
track of their order. For storing/retrieving all of the pictures,
you would just write the array to disk with some sort of header. For
example:
Count As Integer (4 Bytes)
Offset_N As Integer (4 Bytes multiplied by Count)
ImageObjData_N (? Bytes for each ImageObj)
For example:
00000004 Number of objects
00000014 Offset of first object data (byte 20)
00000227 Offset of second object data (byte 551)
0000051A Offset of third object data (byte 1306)
00000904 Offset of fourth object data (byte 2308)
---- Start of first object data
000000F8 X position of first object
00000000 Y position of first object
0000020B Length of PNGData for first object
???????? PNGData for ? bytes
---- Start of second object data
...
---- Start of third object data
...
---- Start of fourth object data
...
---- End Of File
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>