Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Building .dll files using Makefile Pin
JohnCodding13-Oct-23 6:13
JohnCodding13-Oct-23 6:13 
AnswerRe: Building .dll files using Makefile Pin
JohnCodding14-Oct-23 1:00
JohnCodding14-Oct-23 1:00 
QuestionGetVCPFeatureAndVCPFeatureReply fails when called Pin
Valentinor10-Oct-23 4:17
Valentinor10-Oct-23 4:17 
QuestionRe: GetVCPFeatureAndVCPFeatureReply fails when called Pin
CPallini10-Oct-23 4:22
mveCPallini10-Oct-23 4:22 
AnswerRe: GetVCPFeatureAndVCPFeatureReply fails when called Pin
Valentinor10-Oct-23 4:29
Valentinor10-Oct-23 4:29 
GeneralRe: GetVCPFeatureAndVCPFeatureReply fails when called Pin
CPallini10-Oct-23 4:53
mveCPallini10-Oct-23 4:53 
GeneralRe: GetVCPFeatureAndVCPFeatureReply fails when called Pin
Valentinor10-Oct-23 6:51
Valentinor10-Oct-23 6:51 
QuestionI'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch4-Oct-23 14:37
mvahoney the codewitch4-Oct-23 14:37 
C++
// renders a Scalable Vector Graphic (SVG)
// as an ASCII image
// takes a filename and an optional
// numeric percentage for scaling
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gfx.hpp>
using namespace gfx;

// prints a source as 4-bit grayscale ASCII
template <typename Source>
void print_ascii(const Source& src) {
    // the color table
    static const char* col_table = " .,-~;+=x!1%$O@#";
    // move through the draw source
    for (int y = 0; y < src.dimensions().height; ++y) {
        for (int x = 0; x < src.dimensions().width; ++x) {
            typename Source::pixel_type px;
            // get the pixel at the current point
            src.point(point16(x, y), &px);
            // convert it to 4-bit grayscale (0-15)
            const auto px2 = convert<typename Source::pixel_type, gsc_pixel<4>>(px);
            // get the solitary "L" (luminosity) channel value off the pixel
            size_t i = px2.template channel<channel_name::L>();
            // use it as an index into the color table
            putchar(col_table[i]);
        }
        putchar('\r'); putchar('\n');
    }
}
int main(int argc, char** argv) {
    if(argc>1) { // at least 1 param
        float scale = 1; // scale of SVG
        if(argc>2) { // 2nd arg is scale percentage
            int pct = atoi(argv[2]);
            if(pct>0 && pct<1000) {
                scale = ((float)pct/100.0f);
            }
        }
        // open the SVG file
        file_stream fs(argv[1]);
        svg_doc doc;
        // read it
        svg_doc::read(&fs,&doc);
        fs.close();
        // create a bitmap the size of our final scaled SVG
        auto bmp = create_bitmap<gsc_pixel<4>>(
                                {uint16_t(doc.dimensions().width*scale),
                                uint16_t(doc.dimensions().height*scale)});
        // if not out of mem allocating bitmap
        if (bmp.begin()) {
            // clear it
            bmp.clear(bmp.bounds());
            // draw the SVG
            draw::svg(bmp,bmp.bounds(),doc,scale);
            // dump as ascii
            print_ascii(bmp);
            // free the bmp
            free(bmp.begin());
        }
    }
    return (argc<1);
}


And there's this documentation[^]

I was wondering how difficult it is to follow. I'm most interested in terms of what it looks like to use my graphics library as above. Is it confusing? intuitive? I've had precious little feedback on it.

Note that I am not using the STL for things like iostream because this is primarily IoT and embedded, and the STL is limited on some of my targets.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

AnswerRe: I'm looking for review in terms of readability, approachability of this code Pin
Gerry Schmitz4-Oct-23 18:32
mveGerry Schmitz4-Oct-23 18:32 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch4-Oct-23 23:36
mvahoney the codewitch4-Oct-23 23:36 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
Gerry Schmitz5-Oct-23 5:51
mveGerry Schmitz5-Oct-23 5:51 
AnswerRe: I'm looking for review in terms of readability, approachability of this code Pin
Richard MacCutchan4-Oct-23 20:52
mveRichard MacCutchan4-Oct-23 20:52 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch4-Oct-23 23:31
mvahoney the codewitch4-Oct-23 23:31 
AnswerRe: I'm looking for review in terms of readability, approachability of this code Pin
jschell5-Oct-23 5:28
jschell5-Oct-23 5:28 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch5-Oct-23 5:30
mvahoney the codewitch5-Oct-23 5:30 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch5-Oct-23 5:55
mvahoney the codewitch5-Oct-23 5:55 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
k50545-Oct-23 6:35
mvek50545-Oct-23 6:35 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
Gerry Schmitz5-Oct-23 7:54
mveGerry Schmitz5-Oct-23 7:54 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
Richard MacCutchan5-Oct-23 21:46
mveRichard MacCutchan5-Oct-23 21:46 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
jschell6-Oct-23 7:12
jschell6-Oct-23 7:12 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
honey the codewitch6-Oct-23 7:40
mvahoney the codewitch6-Oct-23 7:40 
GeneralRe: I'm looking for review in terms of readability, approachability of this code Pin
Gerry Schmitz6-Oct-23 11:44
mveGerry Schmitz6-Oct-23 11:44 
QuestionFor loop Pin
Calin Negru25-Sep-23 5:27
Calin Negru25-Sep-23 5:27 
AnswerRe: For loop Pin
Victor Nijegorodov25-Sep-23 5:32
Victor Nijegorodov25-Sep-23 5:32 
GeneralRe: For loop Pin
Calin Negru25-Sep-23 5:42
Calin Negru25-Sep-23 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.