mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2026-09-28 23:11:22 -07:00
Convert images when installing
This commit is contained in:
@@ -19,7 +19,6 @@ When booting on a UEFI-based computer, Windows may show a vendor-defined logo wh
|
|||||||
* Start `setup.exe` and follow the instructions.
|
* Start `setup.exe` and follow the instructions.
|
||||||
* You may need to manually disable Secure Boot and then retry.
|
* You may need to manually disable Secure Boot and then retry.
|
||||||
* The installer will launch Paint for editing the image.
|
* The installer will launch Paint for editing the image.
|
||||||
* Be sure to always use the 24-bit BMP/DIB format.
|
|
||||||
* If Windows later restores the original boot loader, just reinstall.
|
* If Windows later restores the original boot loader, just reinstall.
|
||||||
* If you wish to change the image or other configuration, just reinstall.
|
* If you wish to change the image or other configuration, just reinstall.
|
||||||
* For advanced settings, edit `config.txt` before installing. No extra support provided!
|
* For advanced settings, edit `config.txt` before installing. No extra support provided!
|
||||||
@@ -48,9 +47,9 @@ The configuration options are described in `config.txt`, which the installer cop
|
|||||||
|
|
||||||
The image path can be changed in the configuration file. The default path is `[EFI System Partition]\EFI\HackBGRT\splash.bmp`.
|
The image path can be changed in the configuration file. The default path is `[EFI System Partition]\EFI\HackBGRT\splash.bmp`.
|
||||||
|
|
||||||
The image must be a 24-bit BMP file with a 54-byte header. That's a TrueColor BMP3 in Imagemagick, or 24-bit BMP/DIB in Microsoft Paint.
|
If you copy the file to ESP manually, note that the image must be a 24-bit BMP file with a 54-byte header. That's a TrueColor BMP3 in Imagemagick, or 24-bit BMP/DIB in Microsoft Paint.
|
||||||
|
|
||||||
Advanced users may edit the `config.txt` to define multiple images, in which case one is picked at random. The installer copies files whose `path` starts with `\EFI\HackBGRT\`.
|
Advanced users may edit the `config.txt` to define multiple images, in which case one is picked at random. The installer copies and converts files whose `path` starts with `\EFI\HackBGRT\`.
|
||||||
|
|
||||||
## Recovery
|
## Recovery
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@ boot=\EFI\HackBGRT\bootmgfw-original.efi
|
|||||||
# - "remove" to remove the BGRT. Makes x and y meaningless.
|
# - "remove" to remove the BGRT. Makes x and y meaningless.
|
||||||
# - "black" to use only a black image. Makes x and y meaningless.
|
# - "black" to use only a black image. Makes x and y meaningless.
|
||||||
# - "path=..." to read a BMP file.
|
# - "path=..." to read a BMP file.
|
||||||
# * NOTE: The installer will only install files with path=\EFI\HackBGRT\*.
|
# * NOTE: For path=\EFI\HackBGRT\*, the installer will copy and convert the file if necessary.
|
||||||
# * NOTE: The file must be a 24-bit BMP file with a 54-byte header.
|
# * NOTE: For other paths, make sure that the file is a 24-bit BMP file with a 54-byte header.
|
||||||
# * NOTE: The file must be on the EFI System Partition. Do not add a drive letter!
|
# * NOTE: The file must be on the EFI System Partition. Do not add a drive letter!
|
||||||
# Examples:
|
# Examples:
|
||||||
# - image=remove
|
# - image=remove
|
||||||
|
|||||||
+29
-1
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,6 +136,32 @@ public class Setup: SetupHelper {
|
|||||||
Console.WriteLine($"Installed {name} to {newName}.");
|
Console.WriteLine($"Installed {name} to {newName}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install a single image file, with conversion to 24-bit BMP.
|
||||||
|
*/
|
||||||
|
protected void InstallImageFile(string name) {
|
||||||
|
var newName = Path.Combine(InstallPath, name);
|
||||||
|
// Load the image to check if it's valid.
|
||||||
|
Bitmap img;
|
||||||
|
try {
|
||||||
|
img = new Bitmap(name);
|
||||||
|
} catch {
|
||||||
|
throw new SetupException($"Failed to load image {name}.");
|
||||||
|
}
|
||||||
|
// Copy the bitmap into an empty 24-bit image (required by EFI).
|
||||||
|
using (Bitmap bmp = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb)) {
|
||||||
|
using (Graphics g = Graphics.FromImage(bmp)) {
|
||||||
|
g.DrawImageUnscaledAndClipped(img, new Rectangle(Point.Empty, img.Size));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
bmp.Save(newName, ImageFormat.Bmp);
|
||||||
|
} catch {
|
||||||
|
throw new SetupException($"Failed to install image {name} to {newName}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine($"Installed image {name} to {newName}.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install files to ESP.
|
* Install files to ESP.
|
||||||
*/
|
*/
|
||||||
@@ -162,7 +190,7 @@ public class Setup: SetupHelper {
|
|||||||
var delim = "path=\\EFI\\HackBGRT\\";
|
var delim = "path=\\EFI\\HackBGRT\\";
|
||||||
var i = line.IndexOf(delim);
|
var i = line.IndexOf(delim);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
InstallFile(line.Substring(i + delim.Length));
|
InstallImageFile(line.Substring(i + delim.Length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!MsLoader.ReplaceWith(NewLoader)) {
|
if (!MsLoader.ReplaceWith(NewLoader)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user