Skip to content

Instantly share code, notes, and snippets.

View clafferty-powa's full-sized avatar

clafferty-powa

View GitHub Profile
@clafferty-powa
clafferty-powa / portuguese-character-demo.java
Created January 7, 2016 16:58
Android PowaPOS Receipt Builder with Portuguese Characters
String portChars = "\nCapital Vowels\n" +
"À ALT0192 À\n" +
"Á ALT0193 Á\n" +
"Â ALT0194 Â\n" +
"Ã ALT0195 Ã\n" +
"É ALT0201 É\n" +
"Ê ALT0202 Ê\n" +
"Í ALT0205 Í\n" +
"Ó ALT0211 Ó\n" +
"Ô ALT0212 Ô\n" +
@clafferty-powa
clafferty-powa / signfix.m
Created January 6, 2016 20:32
iOS Alpha Channel Signature Fix
UIImage *signatureImage = [UIImage imageNamed:@"testSignature.png"];
//Start an image context (the second param here “YES” says that the context won’t have any alpha channels)
UIGraphicsBeginImageContextWithOptions(signatureImage.size, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// Fill with white:
CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextFillRect(context, (CGRect){ {0,0}, signatureImage.size} );
@clafferty-powa
clafferty-powa / printText
Last active August 29, 2015 14:15
Font and Magnification print test
- (IBAction)printText:(id)sender
{
for (int i=0; i < 11; i++) {
for (int j =9; j < 13; j++) {
[self.powaPOS.printer resetPrinter];
[self.powaPOS.printer printText:[NSString stringWithFormat:@"Font: %d, MagNum %d\n", i, j]];
[self.powaPOS.printer setFont:i];
[self.powaPOS.printer setFormat:j];
NSMutableString *text = [NSMutableString stringWithString:@"\n"];
@clafferty-powa
clafferty-powa / AlphaToBlack
Created January 26, 2015 16:50
Make all pixels with transparency black, and remove their alpha channel on Android Bitmap
// For input image where information is only stored in alpha channel over black RGB.
// Make all pixels with transparency black, and remove alpha channel.
private Bitmap AlphaToBlack(Bitmap image) {
Bitmap rgbImage = image.copy(Bitmap.Config.ARGB_8888, true);
for (int y = 0; y < rgbImage.getHeight(); y++) {
for (int x = 0; x < rgbImage.getWidth(); x++) {
int aPixel = rgbImage.getPixel(x, y);
if (rgbImage.getPixel(x, y) < 0xFF000000)