MosASCII Project Workspace/File Format (MPW/MPF) 1.0B Written by Robert DeFusco This document contains information about the MosASCII Project file format. There are 2 extensions for this file. The first is MPF, MosASCII Project File. Due to a conflict with Microsoft Design Gallery files (MPF), I have changed the extension to MPW, MosASCII Project Workspace. All references to the file format will use the MPW extension. Please note, MPW and MPF files contain the same data format, including the same file ID header. OVERVIEW --------- MosASCII Project Workspace files are used by MosASCII to store project information, such as source image, custom text, font size, output mode, and other settings. MPW files are used to save your projects for backup purposes, or to send them to family/friends over the internet, as it is more efficient to send a compressed MPW file, rather than a large HTML mosaic. MPW FORMAT OVERVIEW ------------ MPF10000 (HEADER ID, 8 BYTE) COMPRESSED DATA (ANY SIZE) HEADER ID --------- MPW file headers start with "MPF", then are followed by the version of MosASCII. The header ID must be 8 bytes. MPF10000 = Version 1.0.000 Version information must be stored in the format #.#.###, with the decimals removed. Therefore 1.0.000 = 10000, and 2.5.150 = 25150 COMPRESSED DATA --------------- The compressed data in an MPW file is compressed using the Catalyst File Encoding ActiveX Control, CSFED32.OCX. READING THE FILE ---------------- You must first read the header. If bytes 1,2,3 are not M,P,F the file is invalid. Next you must load the version information, this is used for compatibility with older versions of MosASCII. EXAMPLE CODE (BASIC) Dim sMPFHeader As String * 8 Dim F as Variant F = FreeFile Open sFileName For Binary Access Read As F Get #F, , sMPFHeader Close F sMPFHeader = Trim(sMPFHeader) If Left(sMPFHeader, 3) = "MPF" Then Dim lVersion As Long lVersion = CLng(Right(sMPFHeader, Len(sMPFHeader) - 3)) If lVersion < 10000 Then MsgBox "You are using an older version than 1.0.000!" Else MsgBox "Invalid MPW File!" End If To load the compressed data, simply go from byte 9 to EOF, then write that data to a temporary file. Pass this file location to the CSFED32.OCX ExpandFile function. EXAMPLE CODE (BASIC) sFileData = Right(sFileData, Len(sFileData) - 8) F = FreeFile Open "temp.000" For Output As F Print #F, sFileData Close F Call FileEncoder1.ExpandFile("temp.000", "temp.001") Kill "temp.000" ' first temp file (contained compressed data) is no longer needed Dim sMPFOutputFile As String * 265 ' Output File, no longer used but reserved ' for compatibility (265 BYTES) Dim sMPFPageCaption As String * 512 ' Page Caption text (512 BYTES) Dim sMPFBGColor As String * 8 ' Background Color data (RGB LONG) (8 BYTES) Dim sMPFFontSize As String * 2 ' Font Size (2 BYTES) Dim sMPFCSSFontSize As String * 6 ' Custom CSS Font Size (6 BYTES) Dim sMPFSpacer As String * 2 ' Spacer Character (2 BYTES) Dim sMPFMode As String * 2 ' Output Mode (2 BYTES) Dim sMPFOIB As String * 1 ' Open in browser, no longer used but reserved ' for compatibility (1 BYTE) Dim sMPFSizeOfCT As String * 8 ' Size of custom text data (8 BYTES) Dim sMPFSizeOfID As String * 8 ' Size of image data (8 BYTES) F = FreeFile Open "temp.001" For Binary Access Read As F Get #F, , sMPFOutputFile Get #F, (265 + 2) + 1, sMPFPageCaption Get #F, (265 + 512 + 2 + 2) + 1, sMPFBGColor Get #F, (265 + 512 + 8 + 2 + 2 + 2) + 1, sMPFFontSize Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 2) + 1, sMPFCSSFontSize Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 6 + 2 + 2) + 1, sMPFSpacer Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 6 + 2 + 2 + 2 + 2) + 1, sMPFMode Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 2 + 6 + 2 + 2 + 2 + 2 + 2) + 1, sMPFOIB Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 1 + 6 + 2 + 2 + 2 + 2 + 2 + 2 + 2) + 1, sMPFSizeOfCT Get #F, (265 + 512 + 8 + 2 + 2 + 2 + 2 + 1 + 8 + 6 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2) + 1, sMPFSizeOfID Close F You will now have the uncompressed project data, the data is as follows. PLEASE NOTE: All data fields have a set size in bytes, if the actual data does not reach the set size the data will be followed by space characters (0x32). Because of this, when using the data, please trim all trailing spaces from the data field. If BASIC you can use the TRIM$(FieldName) function. sMPFOutputFile (265 BYTES), contains the directory that the projects Output Directory was set to sMPFPageCaption (512 BYTES), contains the page caption text of the HTML mosaic, this is the data that goes in the area of the output html sMPFBGColor (8 BYTES), contains the background color of the mosaic. The data in this field is RGB LONG. This means BLACK = 0 and WHITE = 16777215 sMPFFontSize (2 BYTES), contains the font size of the mosaic. This is not the actual font size, but rather the list index of the font size combo box on the MosASCII window. The values are as follows: 0 = -1 1 = -2 2 = 60% CSS 3 = 50% CSS 4 = 40% CSS 5 = 30% CSS 6 = 20% CSS 7 = 10% CSS 8 = Custom CSS Font Size sMPFCSSFontSize (6 BYTES), contains the custom CSS font size information, this includes PT,PX, AND % the information is stored as 100%, 100pt, 100px. PT and PX are case sensitive and MUST BE LOWERCASE sMPFSpacer (2 BYTES), contains the Spacer character information. This is not the actual spacer character, but rather the index of the spacer character combo box on the MosASCII window. The values are as follows: 0 = + 1 = ^ 2 = - 3 = ~ 4 = _ 5 = None sMPFMode (2 BYTES), contains the output mode information. This is the index of the mode combo box on the MosASCII window. The values are as follows: 0 = Custom Text 1 = Random Letters 2 = Random Numbers 3 = Binary 4 = Machine Code 5 = Hex 6 = Smart Text sMPFOIB (1 BYTES), contains the value of the Open in Browser checkbox on MosASCII sMPFSizeOfCT (8 BYTES), contains the length of the custom text data sMPFSizeOfID (8 BYTES), contains the length of the image data After the field data (a combined size of 805 BYTES), is the custom text data. After the custom text data is the RAW bitmap image data (the data output from the VB SavePicture function. You should be able to read the data from 806 TO 806 + sMPFSizeOfCT, to load the custom text. You should be able to read the data from 806 + sMPFSizeOfCT TO 806 + sMPFSizeOfCT + sMPFSizeOfID, to load the image data. EXAMPLE CODE (BASIC) Open "temp.001" For Binary Access Read As F sFileData = Input(LOF(F), #F) sCustomText = Mid(sFileData, 806, sMPFSizeOfCT) sImageData = Mid(sFileData, 806 + sMPFSizeOfCT, sMPFSizeOfID) Close F Kill "temp.001" ' second temp file (contained expanded project data) is no longer needed Now you can output sImageData to a temporary file and load that file to a picture box with the LoadPicture function. EXAMPLE COMPRESSED MPW FILE MPF10145[compressed binary data] EXAMPLE UNCOMPRESSED MPW FILE C:\My Documents\Mosaic1.html[228 SPACES] Default MosASCII Image[490 SPACES] 0[7 SPACES] 8[1 SPACE] 100px[1 SPACE] 3[1 SPACE] 3[1 SPACE] 1 8[7 SPACES] 10240[3 SPACE] MosASCII [10248 BYTES OF BINARY IMAGE DATA] NOTES ----- All the code above was written for this document and may not be the optimal way to read an MPW file. The code may have bugs, or may not function at all, it should only be used as an example to help you write your own loading code. This document should also help you create MPW files, simply create the raw data, then compress it with CSFED32.OCX, and append it a valid MPF header. * IMPORTANT VERSION INFORMATION * MPF 1.0 - FIRST DRAFT MPF 1.0A - MACHINE CODE SUPPORT MPF 1.0B - CUSTOM CSS TEXT SIZE SUPPORT 1.0B ISSUES ----------- MOSASCII VERSION 1.0.149 AND OLDER DOES NOT HAVE CUSTOM CSS DATA When loading/saving a 1.0.149 or older versions do not try to read/write sMPFCSSFontSize data, and please note that this will offset the total field length value, so the above example 806 is invalid. 1.0A ISSUES ----------- MOSASCII VERSION 1.0.116 AND OLDER DO NOT HAVE A MACHINE CODE MODE When loading a 1.0.116 or older version, if the sMPFMode value is 4, read it as 5 (Hex), if the value is 5, read it as 6 (Smart Text). When saving in a format newer than 1.0.116, if you save a Machine Code mode (4), MosASCII versions 1.0.116 and older will load the mode as Hex, if you save a Hex mode (5), MosASCII (1.0.116 and older) will load the mode as Smart Text, if you save a Smart Text mode (7), MosASCII (1.0.116 and older) will crash. The first PUBLIC release of MosASCII to contain MosASCII Project support is version 1.0.131 DOCUMENTATION BY Robert DeFusco MosASCII is Copyright (c) 1998-2001 Robert DeFusco Questions/Comments can be sent to mpf@mosascii.com LAST MODIFIED: 2:57 PM 2/16/2002 #EOF#