Display barcode image in 2.4inch LCD TFT Display without SD card

Hi,
I am trying to display the barcode image in 2.4inch LCD TFT display.Is there any default function like tft.println(""); is used to upload the image?I'm new to this please help me to upload the image without using of SD card.

And it is possible to send a string and image from PHP webpage ?

You have been a member for a while and already made 5 posts.

So you should know that it is wise to post a link to your display and quote which library you are using.

Do you want to generate the barcode from a string or number?
Or just display a ready-made image e.g. from JPEG on your PC?

Post an example of the image you want.

David.

I used below libraries

#include <SPI.h>
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
#include "bitmap_mono.h"

I want to generate a barcode from a barcode NUMBER.

Actually i want to print like this;

Product-Name $ Price
Barcode image

And i used this below function for direct importing:

tft.drawBitmap(10,2,label,30,22,WHITE);

but it returns " no matching function for call to 'MCUFRIEND_kbv::drawBitmap "

Anupriya_Amir:
I want to generate a barcode from a barcode NUMBER.

First you need to know which symbology to use, there are dozens.

With a bit of luck someone will have written a library. Apart from making the stripes, in some symbologies the defintion of which character to print can be quite complex. A bar code isn't always just like a font where instead of a human readable 1 or 2 you print a sequence of stripes.

Even in the ubiquitous EAN-13 (which I haven't worked closely with for decades, must admit) there are iir 3 different stripey patterns for each digit, and which of the 3 version to use depends on which position in the code, and I think also what the start character was. The character sets are A, B and C and it's something like the characters in the left half of the code are all from set A, and the right half is a mix like BCBCCB or some such. So to print an 8 say, if it's in the left half it's the 8's stripey pattern from the A set, and if it's in the right half it's the B or C version of stripes depending on where it is.

Then the barcode often has some kind of checkdigit that's not part of the number: you need to calculate that and then add that to the string.

At the very least you need to add the guard bars at the ends in EAN/UPC or the * in the one whose name I forget.

So unless someone's written a library, you are going to have to read up on the symbology you are using.

elvon_blunden:
which symbology to use, there are dozens.

I am new to this, it's look like hard process..So instead of creating,Now i am trying to import a barcode bitmap value

i used this below function :

tft.drawBitmap(10,2,label,30,22,WHITE);

but it returns " no matching function for call to 'MCUFRIEND_kbv::drawBitmap " . Also i tried

tft.drawRGBBitmap(30,50,label,150,153);

it returns blur image not barcode image.

When you installed MCUFRIEND_kbv with the IDE Library Manager, did you update Adafruit_GFX ?

I provide an example that displays several bitmaps.

Please post the contents of your "label" bitmap e.g. copy-paste from your "bitmap_mono.h"
Or ZIP up your sketch and attach the ZIP here.

And post a link to the original JPG or PNG that your "label" came from. (Or add to your ZIP)

I am happy to help you if you provide the information that I ask for.

David.

I'm confused: OP said they were trying to generate a barcode, but there seems to be artwork already?

(To me, generate a barcode means take the raw human readable text and turn that into stripes according to the rules of the symbology, including guard bars, check digits, changes in character sets etc.)

The original question seems to be about using the Adafruit_GFX drawBitmap() method to display a monochrome image.

Yes, I quite agree. Rendering a fixed monochrome image is different to generating the barcode image from ascii text.

David.

Thread title says "display" then in reply #2 they said "generate". But it does seem they want to display an existing barcode where the stripes have been sorted out already.

Generating barcodes can be a bit of a schlepp, depending on the symbology.

Answering your original question.

You can generate a barcode online e.g. Free Online Barcode Generator: EAN-13

Then convert the .GIF to .JPG or .BMP on the PC.

And generate a C array via http://skaarhoj.com/FreeStuff/GraphicDisplayImageConverter.php

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#include "barcodes.h"

void setup()
{
    uint16_t ID = tft.readID();
    tft.begin(ID);
}

void loop() 
{
    tft.fillScreen(TFT_RED);
    tft.drawBitmap(0, 0, barcode_128x57, 128, 57, TFT_BLACK, TFT_WHITE);
    tft.drawBitmap(0, 64, barcode_226x100, 226, 100, TFT_BLACK, TFT_WHITE);
    delay(5000);
}

The attached ZIP contains the project code.

David.

Anupriya_barcode.zip (1.58 KB)

thank you so much david_prentice it's works fine.Here I'm attached what i tried.Please see and tell me where i'm lacking.I tried this for my basic understanding.

And Actually My assignment is randomly displaying the barcode image and it's corresponding product name from PHP webpage. Is it possible to do this in 2.4 tft LCD?

LCDhello.zip (2.24 KB)

elvon_blunden:
Generating barcodes can be a bit of a schlepp, depending on the symbology.

For the demo purpose i just displayed the barcode image.

My Assignment is Display the product name and corresponding barcode image which is retrieved from PHP page.
In my php page i generated a barcode. I want to pass that barcode into 2.4inch TFT Display.Is it possible to do ?

I hope Now i cleared Your doubt.

Anupriya_Amir:
Is it possible to do ?

I thought this meant you had it working:

Anupriya_Amir:
it's works fine.

But I can't help with the PHP or TFT stuff anyway. I was just originally pointing out that generating a barcode from the raw data is not a simple thing to do from first principles.

I asked you to provide a link to the original image e.g. .JPG or .PNG or .GIF
I also asked you for the style of Barcode.

I had to do some detective work on your code.

  static const unsigned char PROGMEM label [] = { 
    0X00,0X01,0XC8,0X00,0XAA,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
...

actually means

  static const unsigned char PROGMEM label [] = { 
    0X00,0X01,0XC8,0X00,0XAA,0X00,     // width = 200, height = 170
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
...

So you should comment out the size information.

 static const unsigned char PROGMEM label [] = { 
//   0X00,0X01,0XC8,0X00,0XAA,0X00,    //comment out the size information
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
...
  tft.drawBitmap(30,50,label,200,170,WHITE);  //use correct width and height
  ...

It "looks" like an EAN-13 barcode. Do you want to use EAN-13 barcodes?

Your label1[ ] data is not in the ZIP file. So I could only display the 9_501101_530003 barcode in label[ ]

Please answer our questions carefully.
Do you want to generate an EAN-13 barcode from any number?
Or just display an EAN-13 barcode from an image that you know at compile-time?

David.

Edit. The data in label[ ] appears to have come from a "resized" image. The guard lines should be equal width. When you resize an anti-aliased image into a monochrome image of a different size the line widths do not always make a perfect match.
You should make the guard lines one-pixel width. And all the other lines should be multiples of the guard line width.
Or you need to do anti-aliasing on the TFT.

david_prentice:
I asked you to provide a link to the original image e.g. .JPG or .PNG or .GIF

Here i attached,

  • what i want to print on TFT.(label.png)
  • Barcode number from php page (php-page.png)

david_prentice:
Do you want to use EAN-13 barcodes?
just display an EAN-13 barcode from an image that you know at compile-time?

Yes I want to create EAN type barcode image from barcode number (passed from PHP page) at compile time.

david_prentice:
Your label1[ ] data is not in the ZIP file

I derived it in LCDhello.ino

whenever i click my checkbox in PHP webpage(See Attachment), the corresponding product name and barcode should view on TFT Display

php-page.PNG

label.png

Please stop taking the p*ss.

Your PHP image shows a different Barcode_ID
Your label image does not even show an EAN-13 barcode.

You can only store images in Arduino Flash memory at compile time.
Every time you "click" on a product you would have to re-compile your Arduino sketch and upload from your PC.

David.

david_prentice:
Your PHP image shows a different Barcode_ID
Your label image does not even show an EAN-13 barcode.

You can only store images in Arduino Flash memory at compile time.
Every time you "click" on a product you would have to re-compile your Arduino sketch and upload from your PC.

For the Demo purpose i showed this label image.I can't able to display the php data on TFT. This is what my Discussion is..

So Is it possible to create a dynamic barcode(through code like PHP/JS) So that we can able to display on TFT right?

It is up to you.

Provide accurate information and readers might help you.

If you just want to take the p*ss, I will not waste my time.

David.

Anupriya_Amir:
So Is it possible to create a dynamic barcode(through code like PHP/JS) S

Probably, and someone here might even know how to do that; I certainly don't!

For some barcode symbologies, it may just be a matter of changing to the right font, so a 1 prints a certain pattern of stripes, and 2 prints a different one. But for others, and EAN-13 is an example, it's more complex. In EAN each character has three different stripe patterns and the algorithm has to choose the right pattern to use in the right print position.