• Welcome to PlanetSquires Forums.
 

SVG and Barcodes

Started by Petrus Vorster, June 17, 2022, 06:00:04 AM

Previous topic - Next topic

Petrus Vorster

Hi All

I want to re-write my old powerbasic barcode tool to freebasic.
I know my encoder calculations are right, but there has been a significant upgrade from Google fonts in a new Libre128 barcode font. This should eliminate the problem I had with the closing character i had on a free internet font i used.

What i need to do is generate a barcode to SVG format in order to be perfectly scalable for printing. Anything else you have to decide beforehand on sizes and if resized then the scans does not always work.

Do we have a control in Freebasic that can create SVG images?

-Regards, Peter
-Regards
Peter

Paul Squires

#1
A few months ago I was also looking for something that would handle SVG graphics. I did not find anything small enough to include in my project so I decided to just stick with PNG (the cairo.dll file is about 2 to 2.5 MB in size). The Cairo project is the library most cited by FB'ers for SVG manipulation.

https://www.cairographics.org/

From the Download page:

Here is how you can build the library
https://www.cairographics.org/end_to_end_build_for_win32/

Luckily, there appears to be a few places on the net where you can the precompiled DLL binaries such as:
https://preshing.com/20170529/heres-a-standalone-cairo-dll-for-windows/
https://github.com/preshing/cairo-windows/releases

The FB compiler already comes with include files. See the \inc\cairo folder in the compiler toolchain.

I have never used this so I don't have any working code to share.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Wilko Verweij

Hi Petrus, have you considered metafiles? They are perfectly scalable. I love to use them. Not sure if this is an option for you.

Petrus Vorster

Hi Wilko

No I haven't. I don't have even the most basic clue where to start with that.
But I have decided to abandon Freebasic.

I am a 'drag-and-drop' programmer , hobbyist, making small functional tools for work.
(In a collapsed company that cannot care less if you survive or not, or have the means to do your job or not.)

This is not Powerbasic, and Firefly made it so easy and simple that it was great fun for someone like me to just assemble lovely little tools for work.
I have abandoned making tools for work as well.

I am either too stupid for Freebasic or too stupid for the new framework.
I feel lost and cannot even make silly little things work that i used to do in Powerbasic in 10 minutes. I am no longer having fun, but then i don't have anything i want to work on anyway anymore.

Thanks for the advice from everyone.
But i am no longer going to waste everyone's time with my stupid questions.

Cheers.

Peter


-Regards
Peter

Joerg B.

#4
Hello Petrus

What do I have to read...that you want to leave us?
That would be a pity.
You seem to be frustrated and depressed by everything.
Do you really think you are alone in this? That everything only works for everyone else. That is not life.
Not everything works the same for me either. I work as a technical engineer in gas and water supply and sewage disposal. I also "only" program in my spare time on very special subject-related tools and use these tools in the company. If I don't find a solution, I leave it and try to come back to a solution later.
My lecturer at that time in the study was of the opinion that there are no stupid questions, at the most stupid answers.
I think he was right.
In this respect... don't get discouraged and ask your questions.
Most of us learn from it.

Maybe the code from Mr. Scheffers will help you.
https://www.freebasic.net/forum/viewtopic.php?t=27494
Greeting from Germany

Joerg

SeaVipe

Quote from: Petrus Vorster on July 09, 2022, 07:28:18 AMBut I have decided to abandon Freebasic.
Hi Peter,
I genuinely hope you change your mind and stick with Freebasic (and WinFBE)!

I recently hit the "wall" when I realized that I needed to up my game and learn a new database system. The smart money is on SQL but that is so far beyond my dBase/binary file comfort zone that sometimes I could give up altogether. Just the same, I've decided to have a good go at it, though while trying to switch from dBase to SQLite3, I do feel a bit like Sisyphus. As you said in your OP "I don't have even the most basic clue where to start with that." But I can figure it out, and so can you.

As Joerg Buckel wrote
Quotedon't get discouraged and ask your questions. Most of us learn from it.
I know I do.
Clive Richey

Paul Squires

#6
Hang in there Peter! It took a bit of learning (and unlearning) coming from PowerBasic to FreeBasic but once it starts to makes sense, it then makes it hard to go back to PowerBasic. One of the biggest benefits of PowerBasic is the wealth of available code examples available. Translating code from PB to FB can be cumbersome at times because FB is very strict with regards to typing (eg. pointers in PB are DWORD but in FB you need to CAST the value to the correct object it points to... much the same as you do in C). Another pain point with FB is interfacing to DLL's. It always seemed so much easier to deal with DLL's using PB.

FireFly vs. WinFBE.... yes, WinFBE needs to evolve even more these days especially since WinFBE uses it's own GUI framework rather than pure WinAPI.

(edit) and don't forget that Jose's WINFBX framework is INCREDIBLE and you should take the time to view his documentation and look at all of the hundreds of available routines available. It will save you a lot of heartache in the long run.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

Greetings Gents

I nearly did not return here as I decided to drop this whole Freebasic and Programming thing.
Apologies for the Rant.

Its a true midlife crisis. 53. Absolute broke and corrupt employer. Country going down the drain. We currently have to do EVERY SINGLE DAY with 4-6 hours without electricity due to the years of corruption and theft at the national Electricity supplier, roads that will make Romania look like highways and crime waves that is some of the highest in the world.
The Ukraine thing isn't helping either! Prices sky-rocketed on basic food stuffs & fuel.
There is a reason to be depressed!  :)

Not so long ago, after Paul's illness, he too was not in the mood for programming.

I used to like programming (my version of it anyway), but then I had a purpose and a drive to do so. You know when you are all pumped up and wanting to make a contribution?
Now you come to work and the overflowing toilets are running down the office floors and they wont pay for a plumber, There is no cleaning materials, your counter service are minus 4 Terminals, nothing gets fixed....
I tell you, it takes its toll on any man.

Perhaps I should just hang here and see what you bunch are up to, keep my sanity and who knows, one day things may look brighter and I can pick this up again!!!

Thanks for being the nicest bunch of people on the internet!

Regards,

Peter
-Regards
Peter

Bumblebee

When I was in my twenties and working at a hotel, I wanted to create an application to handle transactions and reservations. This hotel was one of the last to use a manual system. I had the programming skills to do it, but the owners would hear none of it. Years later, Hotel Management Software would capture that market.

Programming holds no interest for me, unless I have a project I'm working on. Since this is a hobby, these can be long term projects. Some pet projects I've worked on: playing a decent game of Othello, watermark removal, file/image viewers, backup utility, video editing utilities. Nowadays there are so many well-written apps that it is tempting to just use those, instead of creating my own customized solution.

Hobbies should allow us to escape real life, and not feel like work.
Failed pollinator.

Paul Squires

Good to see you back Peter! Hang in there my friend. Things will get better. We're all here to support each other as best that we can over the bits and bytes of the internet. I can't imagine the turmoil that you and your family and all of the population of your country are going through. Myself, like most "westerners", are spoiled and it is sickening when I see people here take our standard for living for granted and cry and whine over every little inconvenience thrown our way because of the current economic climate after having living through the high excesses of growth and prosperity for so many years. People need to live in other people's shoes for a while in order to appreciate things.

I am coming up to my one year anniversary of my major pulmonary embolism. I feel good these days but, also being 53 years old, I appreciate everything so much more than ever before. I have never been a  drinker or smoker and am "relatively fit" for my age. When I nearly died from massive blood clots in the lungs for no apparent reason, it really made me question everything. Like you've alluded to, programming took a total backseat for me. I just could not get motivated to even look at a line of code. Eventually, I started to gain some interest back and wrote a web based application to help track some investments, etc.

Doing that web programming exposed me deeply to the Visual Studio Code editor which then inspired me to rewrite the WinFBE interface. In the past, like you, my main programming projects were work related (outside of my programmer tools), and being away from work recovering from blood clots also took away a main source of fuel that drove my programming passion. I am now slowly finding other avenues of inspiration in my personal life that give me a bit of passion to write new applications.

Programming will always be a hobby for me so finding passion to create things should be an enjoyable and rewarding experience. Like building something from nothing and enjoying the learning and knowledge building along the way. Like Bumblebee so rightly pointed out... "Hobbies should allow us to escape real life, and not feel like work." I agree 100%!
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

raymw

Hi Peter,

I've got three years or so of temperature values, taken at ten second intervals, over four locations. Do you want to analyse that? I've not yet got round to trying the new winfbe, maybe I will, maybe I won't.

I have sympathy with your rather depressed frame of mind, but you will grow out of it, you can pull yourself up by your boot straps - it is all part of the rich fabric of life.

wrt svg, I use some cad software -openscad- I needed to generate svg files to draw circuit diagrams (revisiting some code I wrote 25 years ago using smalltalk and os/2 - no reason, other than I thought I could) just for fun, I thought I'd try c++. Openscad does not handle import of all svg objects, text, etc, so I generated svg code in c++ for the basic annotation of my electrical networks. I reckon if you can draw a line, then you can draw bar codes. Maybe a bit tedious for you youngsters, who are into cut and paste, but very satisfying re-inventing the wheel.

This was maybe 6 months ago, I've forgotten how, but maybe can get you started. basically find a simple header, then draw shapes with M and L iirc - test it in a browser. The fun with openscad was related to the origin.

        <!--
        resistors
        -->
        <svg xmlns = "http://www.w3.org/2000/svg" >
<circle cx = "100.000" cy = "100.000" r = ".05000" stroke = "black" stroke-width = ".050" fill = "black" />
<circle cx = "200.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<!--<line x1 = "100.000" y1 = "100.000" x2 = "125.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />-->
<line x1 = "175.000" y1 = "100.000" x2 = "200.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "175.000" y1 = "90.000" x2 = "175.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "125.000" y1 = "90.000" x2 = "125.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "125.000" y1 = "90.000" x2 = "175.000" y2= "90.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "125.000" y1 = "110.000" x2 = "175.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "126.000" y = "88.000" class = "small">R1</text><circle cx = "200.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<!--
<circle cx = "300.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "200.000" y1 = "100.000" x2 = "225.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "275.000" y1 = "100.000" x2 = "300.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "275.000" y1 = "90.000" x2 = "275.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "90.000" x2 = "225.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "90.000" x2 = "275.000" y2= "90.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "110.000" x2 = "275.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "226.000" y = "88.000" class = "small">R3</text><circle cx = "300.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
-->
<circle cx = "400.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "300.000" y1 = "100.000" x2 = "325.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "375.000" y1 = "100.000" x2 = "400.000" y2= "100.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "375.000" y1 = "90.000" x2 = "375.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "90.000" x2 = "325.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "90.000" x2 = "375.000" y2= "90.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "110.000" x2 = "375.000" y2= "110.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px Arial; fill: black; }</style>
<text x = "326.000" y = "88.000" class = "small">R2</text><circle cx = "200.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<circle cx = "200.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "200.000" y1 = "100.000" x2 = "200.000" y2= "125.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "200.000" y1 = "175.000" x2 = "200.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "210.000" y1 = "125.000" x2 = "190.000" y2= "125.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "210.000" y1 = "175.000" x2 = "190.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "210.000" y1 = "125.000" x2 = "210.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "190.000" y1 = "125.000" x2 = "190.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "212.000" y = "173.000" class = "small">R6</text><circle cx = "300.000" cy = "100.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<circle cx = "300.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "300.000" y1 = "100.000" x2 = "300.000" y2= "125.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "300.000" y1 = "175.000" x2 = "300.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "310.000" y1 = "125.000" x2 = "290.000" y2= "125.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "310.000" y1 = "175.000" x2 = "290.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "310.000" y1 = "125.000" x2 = "310.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "290.000" y1 = "125.000" x2 = "290.000" y2= "175.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "312.000" y = "173.000" class = "small">r24</text><circle cx = "200.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<circle cx = "300.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "200.000" y1 = "200.000" x2 = "225.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "275.000" y1 = "200.000" x2 = "300.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "275.000" y1 = "190.000" x2 = "275.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "190.000" x2 = "225.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "190.000" x2 = "275.000" y2= "190.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "225.000" y1 = "210.000" x2 = "275.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "226.000" y = "188.000" class = "small">R5</text><circle cx = "300.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<circle cx = "400.000" cy = "200.000" r = "4.000" stroke = "black" stroke-width = "2.000" fill = "black" />
<line x1 = "300.000" y1 = "200.000" x2 = "325.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "375.000" y1 = "200.000" x2 = "400.000" y2= "200.000" stroke-width = "2.000" stroke = "black" />
<line x1 = "375.000" y1 = "190.000" x2 = "375.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "190.000" x2 = "325.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "190.000" x2 = "375.000" y2= "190.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />
<line x1 = "325.000" y1 = "210.000" x2 = "375.000" y2= "210.000" stroke-width = "2.000" stroke = "black" stroke-linecap = "round" />

    <style>.small{ font: 12px sans-serif; fill: black; }</style>
<text x = "326.000" y = "188.000" class = "small">R12</text></svg>

This does not include the code for generating characters - can't readily find that. But W3 has all the info you need. You will only need to get the bar code specification, then a loop to space the lines as needed.

Best wishes,

Ray

raymw

forgot to add, you don't need to display svg graphics in freebasic, just open your browser. You only need to generate the svg code, probably a succinct routine..

Petrus Vorster

Hi Ray

My Pb tool used Postal scanned barcodes of items, created SMS messages in a bundle to customers and then printed a scan sheet for the employees to go scan into the Database.[And then send the messages via a Cellphone company]
(My 3rd party code were not permitted direct access to the national database)
It saved a lot of time when staff instead had to drag a lot of mail items to where they could still find a working computer.

There were no display needs, but printer output was done using a barcode font (Code39).
I wanted to move it up to Code128. Encoding and check digit much more difficult.
However, the resulting Barcode is MUCH shorter and better quality.
The plan was to have the output to a label printer( hence the SVG for scaling ), and there code39 prints poorly on a thermal head.

But that was just a dream. That whole organization imploded.
I am currently not going to pursue the barcodes further. My current code works.

I am following what the rest of you are up too on the moment.

-regards, Peter

-Regards
Peter

Wilko Verweij

I also quit Freebasic. Too many unexpected and strange things happening after compiling. It is a pity because the Firefly community was always very helpful and friendly, unlike some other forums. Now switched to C, different, but I understand most things now. @Petrus, stay strong, if there is ever a need to explore metafiles, let me know. Sure I can get you started.