Code Monkey home page Code Monkey logo

Comments (5)

ncannasse avatar ncannasse commented on June 16, 2024

The common format to represent pixels is BGRA stored in low endian (so bytes in BGRA order). But maybe i should make it more explicit by taking the hxd.Pixels class from Heaps.io and porting it to format, but then it's tight to hxd.BitmapData, etc. https://github.com/ncannasse/heaps/blob/master/hxd/Pixels.hx

from format.

azrafe7 avatar azrafe7 commented on June 16, 2024

To clarify:

it seems that currently the code would only work with 32bpp bitmaps (

var a = px >>> 24;
var r = (px >> 16) & 0xFF;
var g = (px >> 8) & 0xFF;
var b = px & 0xFF;
), while the common format is 24bpp. Moreover the common way to store BMPs it bottomToTop (i.e. line-by-line, starting from the bottom-most one, with bytes padded to be a multiple of 4 - if I understood the spec correctly), and that's why I get a flipped image with weird bandings.

I think that Data and Header should represent the format in a closer way, and delegate the conversion to more familiar/easier formats to other functions (like png and gif do, with exctract___ and build___ methods).

I'm not sure it's worth the effort to fix this specific one (due to the fact that BMP is unefficient when compared to png and other formats), but at the same time I thought it would be useful to bring the subject up.

Having some directions on what is the expected way to write support for other file formats and expand this lib would be great!

from format.

ncannasse avatar ncannasse commented on June 16, 2024

In general, when an image has been decoded in format library, it's usually represented in memory / bytes as a top-down 32bits data.

from format.

azrafe7 avatar azrafe7 commented on June 16, 2024

Yes, that's what extractARGB/BGRA() would eventually do. But do you agree that Data should represent the binary file more closely (so that, f.e., modifying it in place and writing it back to disk doesn't need any type of conversion)?

from format.

ncannasse avatar ncannasse commented on June 16, 2024

yes, I agree, it should be as much near from the file data, especially if it's read directly as it.

from format.

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.