Giter Site home page Giter Site logo

Pixel layout & console output about svgren HOT 5 CLOSED

luc4s avatar luc4s commented on August 14, 2024
Pixel layout & console output

from svgren.

Comments (5)

igagis avatar igagis commented on August 14, 2024

Hi,

  1. The pixel format is somewhat outside of the library's scope. Internaly, rendering is done in RGBA 32 bit format, it is not possible to change it in runtime. So, supporting different pixel formats would mean converting the pixels after rasterization is done, and this looks like a functionality of some raster image manipulation library. Writing such conversion functions yourself is not a difficult task.

  2. As far as I see, there should be no console output in normal operation in both debug and release builds. In release build there should be no any console output at all. In debug build there is some console output about some abnormal or suspicious situations. Do you use NuGet version of the library? Could you give examples of what console output you observe?

from svgren.

luc4s avatar luc4s commented on August 14, 2024
  1. I already did implement such rearrangement myself, but since there is already some per pixel formatting happening there:
    std::vector<pixel> canvas::release(){
    #if SVGREN_BACKEND == SVGREN_BACKEND_CAIRO
    auto& ret = this->pixels;
    #elif SVGREN_BACKEND == SVGREN_BACKEND_AGG
    ASSERT(!this->group_stack.empty())
    auto& ret = this->group_stack.front().pixels;
    #endif
    for(auto &c : ret){
    #if SVGREN_BACKEND == SVGREN_BACKEND_CAIRO
    // swap red and blue channels, as cairo works in BGRA format, while we need to return RGBA
    c = (c & 0xff00ff00) | ((c << 16) & 0xff0000) | ((c >> 16) & 0xff);
    #endif
    // unpremultiply alpha
    pixel a = (c >> 24);
    if(a == 0xff){
    continue;
    }
    if(a != 0){
    using std::min;
    pixel r = (c & 0xff) * 0xff / a;
    r = min(r, pixel(0xff)); // clamp top
    pixel g = ((c >> 8) & 0xff) * 0xff / a;
    g = min(g, pixel(0xff)); // clamp top
    pixel b = ((c >> 16) & 0xff) * 0xff / a;
    b = min(b, pixel(0xff)); // clamp top
    c = ((a << 24) | (b << 16) | (g << 8) | r);
    }else{
    c = 0;
    }
    }
    return std::move(ret);
    }

    I thought an option could have been added.
  2. Here is a sample of debug messages I get when loading an SVG:
selector END
selector chain END
property name: fill
property value: #008DD0
style properties END
selector class: AccentRoot
selector END
selector chain END
property name: fill
property value: #FF5504
style properties END
crawler::reset(): invoked
crawler::reset(): invoked
crawler::reset(): invoked
crawler::reset(): invoked

The SVG contains some CSS, could it be the reason?

from svgren.

igagis avatar igagis commented on August 14, 2024
  1. The BGR->RGB conversion in the code is only done for Cairo backend which is not used anymore, instead AGG is the default backend now which does not require that BGR->RGB.

  2. Ok, the output comes when loading SVG, then it comes from svgdom and cssdom libraries. I'll remove those prints.

from svgren.

igagis avatar igagis commented on August 14, 2024

Ok, I have removed the console output. Just update cssdom and svgdom to latest versions.

from svgren.

luc4s avatar luc4s commented on August 14, 2024

Great, thank you 👍.

from svgren.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.