--- /dev/null
+<component name="libraryTable">
+ <library name="sanselan-0.98-snapshot">
+ <CLASSES>
+ <root url="jar://$PROJECT_DIR$/../../lib/sanselan-0.98-snapshot.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+</component>
\ No newline at end of file
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="community-resources" />
<orderEntry type="library" name="jdom" level="project" />
+ <orderEntry type="library" name="sanselan-0.98-snapshot" level="project" />
</component>
</module>
+++ /dev/null
-/*
- * Copyright 2006 ProductiveMe Inc.
- * Copyright 2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.pme.exe.res.bmp;
-
-import com.pme.exe.Bin;
-
-/**
- * Date: May 3, 2006
- * Time: 12:34:47 PM
- */
-public class BitmapFileHeader extends Bin.Structure{
- public BitmapFileHeader() {
- super("Bitmap File Header");
- addMember( new Word( "bfType" ) );
- addMember( new DWord( "bfSize" ) );
- addMember( new Word( "bfReserved1" ) );
- addMember( new Word( "bfReserved2" ) );
- addMember( new DWord( "bfOffBits" ) );
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 ProductiveMe Inc.
- * Copyright 2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.pme.exe.res.bmp;
-
-import com.pme.exe.Bin;
-
-import java.io.File;
-import java.io.DataInput;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-/**
- * Date: May 3, 2006
- * Time: 12:33:01 PM
- */
-public class BmpFile extends Bin.Structure {
- private File myFile;
- private BitmapFileHeader myHeader = new BitmapFileHeader();
-
- public BmpFile(File file) {
- super(file.getName());
- myFile = file;
- addMember( myHeader );
- }
-
- public void read() throws IOException {
- RandomAccessFile stream = null;
- try {
- stream = new RandomAccessFile(myFile, "r");
- read(stream);
- } finally {
- if (stream != null) {
- stream.close();
- }
- }
- }
-
- public void read(DataInput stream) throws IOException {
- super.read(stream);
- Value bfSize = myHeader.getValueMember("bfSize");
- long size = bfSize.getValue() - sizeInBytes();
- Bytes bytes = new Bytes( "Data", size );
- bytes.read( stream );
- addMember( bytes );
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 ProductiveMe Inc.
- * Copyright 2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.pme.exe.res.bmp;
-
-import com.pme.exe.res.DirectoryEntry;
-import com.pme.exe.res.RawResource;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-/**
- * Date: May 3, 2006
- * Time: 1:00:08 PM
- */
-public class PictureResourceInjector {
- public class PictureWrongFormat extends IOException {
- public PictureWrongFormat(File file) {
- super("Picture file is not found: " + file.getPath());
- }
- }
-
- public void inject(File file, DirectoryEntry root, String resourceId) throws IOException {
- byte[] bytes = new byte[(int) file.length()];
- RandomAccessFile stream = null;
- try {
- stream = new RandomAccessFile(file, "r");
- stream.read(bytes);
- }
- catch (IOException exception) {
- throw new PictureWrongFormat(file);
- }
- finally {
- if (stream != null) {
- stream.close();
- }
- }
- DirectoryEntry subDirBmp = root.findSubDir("IRD2").findSubDir(resourceId);
- RawResource bmpRes = subDirBmp.getRawResource(0);
- bmpRes.setBytes(bytes);
- }
-
-}
package com.pme.launcher;
+import com.pme.exe.Bin;
import com.pme.exe.ExeReader;
import com.pme.exe.SectionReader;
-import com.pme.exe.Bin;
-import com.pme.exe.res.*;
-import com.pme.exe.res.bmp.PictureResourceInjector;
+import com.pme.exe.res.DirectoryEntry;
+import com.pme.exe.res.RawResource;
+import com.pme.exe.res.ResourceSectionReader;
+import com.pme.exe.res.StringTableDirectory;
import com.pme.exe.res.icon.IconResourceInjector;
import com.pme.exe.res.vi.VersionInfo;
import com.pme.util.OffsetTrackingInputStream;
public class LauncherGenerator {
private File myTemplate;
private File myIcon;
- private File myBmp;
private File myExePath;
private StringTableDirectory myStringTableDirectory;
private DirectoryEntry myRoot;
iconInjector.injectIcon(myIcon, myRoot, "IRD101");
}
- if (myBmp != null) {
- PictureResourceInjector bmpInjector = new PictureResourceInjector();
- bmpInjector.inject(myBmp, myRoot, "IRD104");
- }
-
DirectoryEntry viDir = myRoot.findSubDir("IRD16").findSubDir( "IRD1" );
Bin.Bytes viBytes = viDir.getRawResource( 0 ).getBytes();
ByteArrayInputStream bytesStream = new ByteArrayInputStream(viBytes.getBytes());
public void setResourceString(int id, String value) {
myStringTableDirectory.setString(id, value);
}
+
+ public void injectBitmap(int id, byte[] bitmapData) {
+ DirectoryEntry subDirBmp = myRoot.findSubDir("IRD2").findSubDir("IRD" + id);
+ RawResource bmpRes = subDirBmp.getRawResource(0);
+ bmpRes.setBytes(bitmapData);
+ }
}
package com.pme.launcher;
+import org.apache.sanselan.ImageFormat;
+import org.apache.sanselan.Sanselan;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
+import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.Charset;
import java.util.HashMap;
File template = new File(args[0]);
if (!template.exists()) {
System.err.println("Launcher template EXE file " + args[0] + " not found");
- System.exit(1);
+ System.exit(2);
}
InputStream appInfoStream = LauncherGeneratorMain.class.getClassLoader().getResourceAsStream(args[1]);
if (appInfoStream == null) {
System.err.println("Application info file " + appInfoStream + " not found");
- System.exit(1);
+ System.exit(3);
}
Document appInfo;
try {
appInfo = new SAXBuilder().build(appInfoStream);
} catch (Exception e) {
System.err.println("Error loading application info file " + appInfoStream + ": " + e.getMessage());
- System.exit(1);
+ System.exit(4);
+ return;
+ }
+
+ String splashUrl = appInfo.getRootElement().getChild("logo").getAttributeValue("url");
+ if (splashUrl.startsWith("/")) {
+ splashUrl = splashUrl.substring(1);
+ }
+ InputStream splashStream = LauncherGeneratorMain.class.getClassLoader().getResourceAsStream(splashUrl);
+ if (splashStream == null) {
+ System.err.println("Splash screen image file file " + splashUrl + " not found");
+ System.exit(5);
+ }
+
+ ByteArrayOutputStream splashBmpStream = new ByteArrayOutputStream();
+ try {
+ BufferedImage bufferedImage = Sanselan.getBufferedImage(splashStream);
+ Sanselan.writeImage(bufferedImage, splashBmpStream, ImageFormat.IMAGE_FORMAT_BMP, new HashMap());
+ }
+ catch (Exception e) {
+ System.err.println("Error converting splash screen to BMP: " + e.getMessage());
+ System.exit(6);
}
Map<String, Integer> resourceIDs;
}
catch (Exception e) {
System.err.println("Error loading resource.h: " + e.getMessage());
- System.exit(1);
+ System.exit(7);
return;
}
}
catch (IOException e) {
System.err.println("Error loading launcher properties: " + e.getMessage());
- System.exit(1);
+ System.exit(8);
}
LauncherGenerator generator = new LauncherGenerator(template, new File(args[4]));
Integer id = resourceIDs.get(key);
if (id == null) {
System.err.println("Invalid stringtable ID found: " + key);
- System.exit(1);
+ System.exit(9);
}
generator.setResourceString(id, (String) pair.getValue());
}
+ generator.injectBitmap(resourceIDs.get("IDB_SPLASH"), splashBmpStream.toByteArray());
+
generator.generate();
} catch (IOException e) {
e.printStackTrace();
+ System.exit(10);
}
}