some additional bullshit such as printing arbitrary text as bitmaps
This commit is contained in:
parent
ad8a799c18
commit
e9d702f955
|
@ -14,10 +14,11 @@ namespace libpaperang {
|
||||||
public byte End;
|
public byte End;
|
||||||
}
|
}
|
||||||
public enum Model {
|
public enum Model {
|
||||||
P1,
|
P1, // Original model; 57mm feed, 48-byte lines (200DPI), LiPo battery (1Ah)
|
||||||
T1,
|
P1S,// Original "special edition" model; identical to P1 but in different colours
|
||||||
P2,
|
T1, // Label printer model; 15mm feed, unknown-byte lines, 4xAAA battery
|
||||||
P2S
|
P2, // Hi-DPI model; 57mm feed, 96-byte lines (300DPI), LiPo battery (1Ah)
|
||||||
|
P2S // Hi-DPI "special edition" model; identical to P2 but includes Pomodoro timer functionality
|
||||||
}
|
}
|
||||||
public enum State {
|
public enum State {
|
||||||
Offline,
|
Offline,
|
||||||
|
@ -36,6 +37,7 @@ namespace libpaperang {
|
||||||
CrcTransmit,
|
CrcTransmit,
|
||||||
Print
|
Print
|
||||||
}
|
}
|
||||||
|
//I'm sure there are other opcodes available but these are the "core" ones implemented by the official MiaoMiaoJi chinese Windows and OSX apps
|
||||||
public struct Opcodes {
|
public struct Opcodes {
|
||||||
public byte[] NoOp;
|
public byte[] NoOp;
|
||||||
public byte[] LineFeed;
|
public byte[] LineFeed;
|
||||||
|
|
|
@ -46,7 +46,22 @@ namespace paperangapp {
|
||||||
logger.Debug("PrinterInitialised? " + mmj.Printer.PrinterInitialised);
|
logger.Debug("PrinterInitialised? " + mmj.Printer.PrinterInitialised);
|
||||||
logger.Debug("Printer initialised and ready");
|
logger.Debug("Printer initialised and ready");
|
||||||
}
|
}
|
||||||
private void BtTestLine_Click(object sender, RoutedEventArgs e) => mmj.Feed(200);
|
private void BtTestLine_Click(object sender, RoutedEventArgs e) {
|
||||||
|
string Font="Consolas";
|
||||||
|
int FontSize=48;
|
||||||
|
|
||||||
|
Bitmap b=new Bitmap(mmj.Printer.LineWidth*8, (FontSize+4)*10);
|
||||||
|
g=Graphics.FromImage(b);
|
||||||
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||||
|
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||||
|
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||||
|
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
|
||||||
|
g.DrawString("hello", new Font(Font, FontSize), Brushes.Black, new RectangleF(0, 0, b.Width, b.Height));
|
||||||
|
g.Flush();
|
||||||
|
PrintBitmap(b);
|
||||||
|
g.Dispose();
|
||||||
|
b.Dispose();
|
||||||
|
}
|
||||||
private void BtLoadImage_Click(object sender, RoutedEventArgs e) {
|
private void BtLoadImage_Click(object sender, RoutedEventArgs e) {
|
||||||
logger.Debug("Loading image for print");
|
logger.Debug("Loading image for print");
|
||||||
OpenFileDialog r = new OpenFileDialog {
|
OpenFileDialog r = new OpenFileDialog {
|
||||||
|
@ -68,6 +83,9 @@ namespace paperangapp {
|
||||||
logger.Debug("Loaded image as Bitmap");
|
logger.Debug("Loaded image as Bitmap");
|
||||||
_.Dispose();
|
_.Dispose();
|
||||||
logger.Debug("Disposed of Image");
|
logger.Debug("Disposed of Image");
|
||||||
|
PrintBitmap(bimg);
|
||||||
|
}
|
||||||
|
private void PrintBitmap(Bitmap bimg) {
|
||||||
bimg = CopyToBpp(bimg);
|
bimg = CopyToBpp(bimg);
|
||||||
logger.Debug("Converted Bitmap to Bitmap with 1-bit colour depth");
|
logger.Debug("Converted Bitmap to Bitmap with 1-bit colour depth");
|
||||||
//BitArray img = new BitArray(bimg.Height*96*8);
|
//BitArray img = new BitArray(bimg.Height*96*8);
|
||||||
|
|
Loading…
Reference in New Issue