ImageCompiler

eww245

Member
Licensed User
ImageCompiler is a small Desktop only program written in Basic4ppc that will embed images into a .dll
Both .Net Framework 2.0 and .Net CompactFramework 2.0 are required.

The resulting library can be used for the Device and Desktop, a Desktop only option is included.
It will contain two methods.

GetBitmap - returns a standard .Net Bitmap
GetStream - returns the raw data as a Stream

For all of the images embedded there will be a property that gets the resource name as a string.

ImageCompiler.GetBitmap(ImageCompiler.ImageName) - will return a Bitmap
ImageCompiler.GetStream(ImageCompiler.ImageName) - will return a Stream
This can be used with my http://www.b4x.com/forum/additional-libraries/4952-alpha-image-device.html library on the Device or Desktop

The program source is available and has comments on how to draw to an Image object or to an AlphaImage object.

It is possible to embed any type of file into the library.
I haven't tested it but, the BinaryFile library should be able to read the Stream data or write it to a file.
Edit: Yes it does work with any file and with BinaryFile library.
 

Attachments

  • ImageCompiler4.zip
    23.6 KB · Views: 50
Last edited:

Aspire89

Member
Licensed User
Thank you. A very useful application, but on Windows 7, not created .dll file. In the folder with .exe is created .cs file and all. . Net Framework 2.0 and. Net CompactFramework 2.0 installed. In what could be the problem? :sign0085:
 

eww245

Member
Licensed User
Thank you. A very useful application, but on Windows 7, not created .dll file. In the folder with .exe is created .cs file and all. . Net Framework 2.0 and. Net CompactFramework 2.0 installed. In what could be the problem? :sign0085:


Try the new version. It now should check for a 64bit system and "C:\" drive was replaced with "\" to be sure the path is the system drive.

Let me know if it works..
 

Aspire89

Member
Licensed User
Tried, still does not work. System 32 bit. If you do not add a single image, then created .dll file size of 3.5 kb. When compiling a console window appears but does not have time to read the text of the error. Examined the way, all the folders and files exist. :confused:
 

eww245

Member
Licensed User
Tried, still does not work. System 32 bit. If you do not add a single image, then created .dll file size of 3.5 kb. When compiling a console window appears but does not have time to read the text of the error. Examined the way, all the folders and files exist. :confused:

Ok So it at least finds the .Net libraries, I thought that was the problem.
If the image name is for ex, img...png it won't work.
If it is file.img.png it should work but it would end up being just img.png.
What about a space in the file or library name, I don't think I included the "" quotes for those parameters.

Did you only try with Windows 7?
I'll add a log file output and or use a bat file so we can see what is happening.

Edit: Nevermind my fault I missed 1 " quote.:BangHead:
Basic4ppc won't see it as an error only the C# compiler.
Not sure how I missed this one, others should have had the same problem.
I'll fix it when I get home from work.
 
Last edited:

eww245

Member
Licensed User
There was a problem with adding files from a drive other than the system drive.
It would only compile if the last file was the system drive.
This was due to removing the C: for the .Net libraries path.

Now it will search for the drive with the windows directory until it is found.
Version number and copyright info can be added to the library.

Here is some code using the BinaryFile library for anyone interested in compiling files rather than images.
Or wanting to save an image to file.

B4X:
Sub Globals
  Dim bytes(0) As Byte
End Sub

Sub App_Start
  Compiler.New1

  'Get the raw bytes
  bin.New1(Compiler.GetStream(Compiler.FileName), false)
  Dim bytes(bin.Length) As Byte
  bin.ReadBytes(bytes(), ArrayLen(bytes()))

  'Save it to a file
  FileOpen(f, "file.ext", cRandom)
    bin.New1(f, false)
    bin.WriteBytes(bytes())
  FileClose(f)
 bytes() = 0
End Sub
 
Last edited:

Aspire89

Member
Licensed User
A small request. Move the list of add images in a separate file. For example list.txt, containing:
c:\1.jpg
c:\2.jpg
c:\3.jpg
etc.
When more than 20 images, uncomfortable one file to add.
Thank you.
 

susu

Well-Known Member
Licensed User
Longtime User
I tried to combine a picture with a text file. When I load dll, the picture is ok but the text file is not. Can you suggest another solution? :sign0085:
 
Top