Em Andamento

Convert a script from C# to javascript/nodejs to print image to POS Printer (ESCP)

You may use whatever nodejs module (npm) you want in order to accomplish the goal.

The goal is to create a command string that will be created with the script and it will be placed in the buffer.

Below you may see the script that I want to be converted to nodejs/javascript.

public string GetLogo()

{

string logo = "";

if (![url removed, login to view](@"C:\[url removed, login to view]"))

return null;

BitmapData data = GetBitmapData(@"C:\[url removed, login to view]");

BitArray dots = [url removed, login to view];

byte[] width = [url removed, login to view]([url removed, login to view]);

int offset = 0;

MemoryStream stream = new MemoryStream();

BinaryWriter bw = new BinaryWriter(stream);

[url removed, login to view]((char)0x1B);

[url removed, login to view]('@');

[url removed, login to view]((char)0x1B);

[url removed, login to view]('3');

[url removed, login to view]((byte)24);

while (offset < [url removed, login to view])

{

[url removed, login to view]((char)0x1B);

[url removed, login to view]('*'); // bit-image mode

[url removed, login to view]((byte)33); // 24-dot double-density

[url removed, login to view](width[0]); // width low byte

[url removed, login to view](width[1]); // width high byte

for (int x = 0; x < [url removed, login to view]; ++x)

{

for (int k = 0; k < 3; ++k)

{

byte slice = 0;

for (int b = 0; b < 8; ++b)

{

int y = (((offset / 8) + k) * 8) + b;

// Calculate the location of the pixel we want in the bit array.

// It'll be at (y * width) + x.

int i = (y * [url removed, login to view]) + x;

// If the image is shorter than 24 dots, pad with zero.

bool v = false;

if (i < [url removed, login to view])

{

v = dots[i];

}

slice |= (byte)((v ? 1 : 0) << (7 - b));

}

[url removed, login to view](slice);

}

}

offset += 24;

[url removed, login to view]((char)0x0A);

}

// Restore the line spacing to the default of 30 dots.

[url removed, login to view]((char)0x1B);

[url removed, login to view]('3');

[url removed, login to view]((byte)30);

[url removed, login to view]();

byte[] bytes = [url removed, login to view]();

return logo + [url removed, login to view](bytes);

}

public BitmapData GetBitmapData(string bmpFileName)

{

using (var bitmap = (Bitmap)[url removed, login to view](bmpFileName))

{

var threshold = 127;

var index = 0;

double multiplier = 570; // this depends on your printer model. for Beiyang you should use 1000

double scale = (double)(multiplier/(double)[url removed, login to view]);

int xheight = (int)([url removed, login to view] * scale);

int xwidth = (int)([url removed, login to view] * scale);

var dimensions = xwidth * xheight;

var dots = new BitArray(dimensions);

for (var y = 0; y < xheight; y++)

{

for (var x = 0; x < xwidth; x++)

{

var _x = (int)(x / scale);

var _y = (int)(y / scale);

var color = [url removed, login to view](_x, _y);

var luminance = (int)(color.R * 0.3 + color.G * 0.59 + color.B * 0.11);

dots[index] = (luminance < threshold);

index++;

}

}

return new BitmapData()

{

Dots = dots,

Height = (int)([url removed, login to view]*scale),

Width = (int)([url removed, login to view]*scale)

};

}

}

public class BitmapData

{

public BitArray Dots

{

get;

set;

}

public int Height

{

get;

set;

}

public int Width

{

get;

set;

}

}

Habilidades: Javascript, node.js

Ver mais: convert script image file pos, set bit in c, set a bit in c, k to the i, int v, int i, goal zero, get location javascript, get length of string in c, dot pixel, dot int, create logo dimensions, create bmp logo, create a logo from file, convert c to javascript, c for int, a new mode, a dot b dot c, print image, pos printer, pos data, offset printer, nodejs, javascript nodejs, image to data

Acerca do Empregador:
( 28 comentários ) SOFIA, Bulgaria

ID do Projeto: #6778333

Premiar a:

phuctq

Thank you for posting this project .I have more than 5 years experience on C# / javascript. I am ready to start the work right now. I'm looking forward to waiting for your reply. I can work in Wordpress, Joomla, Mage Mais

$50 USD em 3 dias
(0 Avaliações)
0.0

3 freelancers estão ofertando em média $144 para este trabalho

dsdenes

We are a professional developer team of 3 developers and a project manager located in Berlin. It supposed to be needed to cover the whole process with tests too.

$217 USD in 2 dias
(1 Comentário)
4.4
biplob1outsource

Hello, I am proficient using HTML, CSS, PHP, Flash, ActionScript, Java and C/C++. I understand your job. I am little busy with my other big job. If you give me 2 days then I can fix this issue. Regards, Biplob

$111 USD em 1 dia
(0 Comentários)
0.0
ETSPL

Hi , We have significant experience in node.js project. We can provide references on request. Regards Ennovations

$105 USD in 2 dias
(0 Comentários)
0.0