You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
// Define variable to prevent hacking
|
|
define('IN_CB',true);
|
|
|
|
// Including all required classes
|
|
require('class_barcode/index.php');
|
|
require('class_barcode/FColor.php');
|
|
require('class_barcode/BarCode.php');
|
|
require('class_barcode/FDrawing.php');
|
|
|
|
// including the barcode technology
|
|
include('class_barcode/code128.barcode.php');
|
|
$code = $_GET['code'];
|
|
// Creating some Color (arguments are R, G, B)
|
|
$color_black = new FColor(0,0,0);
|
|
$color_white = new FColor(255,255,255);
|
|
|
|
/* Here is the list of the arguments:
|
|
1 - Thickness
|
|
2 - Color of bars
|
|
3 - Color of spaces
|
|
4 - Resolution
|
|
5 - Text
|
|
6 - Text Font (0-5) */
|
|
$code_generated = new code128(35,$color_black,$color_white,1,$code,3);
|
|
|
|
/* Here is the list of the arguments
|
|
1 - Width
|
|
2 - Height
|
|
3 - Filename (empty : display on screen)
|
|
4 - Background color */
|
|
$drawing = new FDrawing(1024,1024,'',$color_white);
|
|
$drawing->init(); // You must call this method to initialize the image
|
|
$drawing->add_barcode($code_generated);
|
|
$drawing->draw_all();
|
|
$im = $drawing->get_im();
|
|
|
|
// Next line create the little picture, the barcode is being copied inside
|
|
$im2 = imagecreate($code_generated->lastX,$code_generated->lastY);
|
|
imagecopyresized($im2, $im, 0, 0, 0, 0, $code_generated->lastX, $code_generated->lastY, $code_generated->lastX, $code_generated->lastY);
|
|
$drawing->set_im($im2);
|
|
|
|
// Header that says it is an image (remove it if you save the barcode to a file)
|
|
header('Content-Type: image/png');
|
|
|
|
// Draw (or save) the image into PNG format.
|
|
//$hasil = $drawing->finish(IMG_FORMAT_PNG);
|
|
$drawing->finish(IMG_FORMAT_PNG);
|
|
?>
|