Commit graph

365 commits

Author SHA1 Message Date
Gered 7209907193 change to a better tint color used in visual test
figure it is best to use a color that contains all different and
non-zero RGB components
2023-03-26 17:59:42 -04:00
Gered b94ef4df4e add visual tests for BlendFunction blending 2023-03-26 17:45:22 -04:00
Gered d2bc28754f add visual tests for RgbaBitmap blended drawing primitives 2023-03-26 16:57:22 -04:00
Gered f233f810e6 add RgbaBitmap blended drawing primitives 2023-03-26 16:36:53 -04:00
Gered 5c2571755a update blended_pixel_drawing visual test to test an unchecked method too 2023-03-26 16:29:55 -04:00
Gered d238031166 update blended_rect visual test to reflect bug fix
the previous commit fixed a minor 1-pixel-off issue related to
clipping
2023-03-26 16:29:07 -04:00
Gered 3864f36706 update IndexedBitmap blended primitives to use new generic functions 2023-03-26 16:27:14 -04:00
Gered a667a657d2 add generic primitive drawing methods accepting custom pixel functions 2023-03-26 16:26:15 -04:00
Gered 847149607d some cleanups and fixes 2023-03-26 13:49:16 -04:00
Gered 48a76a59e0 add visual tests for the new blending RgbaBitmap blit methods
note that we're not testing all of the different blend combinations
for each blit method. specific BlendFunction visual tests will be added
2023-03-26 13:15:56 -04:00
Gered 0345571851 reorder blit method enums in a different and still arbitrary order 2023-03-26 12:37:54 -04:00
Gered b38a4b55bc add RgbaBitmap blending blit methods 2023-03-25 19:09:01 -04:00
Gered 050c2ac6e9 add color blending and tinting functions
this is definitely one of those things where i wonder if there are
probably better names (more standardized names) that could be used
here instead
2023-03-25 19:08:20 -04:00
Gered a087c35024 add pixel format option to RgbaBitmap png saving 2023-03-24 20:11:08 -04:00
Gered 29ab739323 update IndexedBitmap graphics visual tests to match the rgb tests 2023-03-21 21:20:35 -04:00
Gered 9dcfa91502 add graphics visual tests for RgbaBitmap drawing operations
obviously only for the operations implemented so far. there are going
to be more in the near future.
2023-03-21 21:19:37 -04:00
Gered bb4a3655dc update graphics visual test references images that used the vga palette
necessary after the previous change fixing the 6-bit to 8-bit
conversion
2023-03-21 18:21:26 -04:00
Gered 1f232c51bb fix 6-bit to 8-bit palette conversion
this now produces "full range" results, e.g. VGA color 15 (bright white)
now converts to 255,255,255 instead of 252,252,252.
2023-03-21 18:20:36 -04:00
Gered ba75ae04f1 set default pixel color for new Bitmap's differently based on type
this is mainly to prevent RgbaBitmap's from being initialized by
default to all black with alpha=0. this can still be manually done if
desired, but the assumption is that most of the time you'd want
alpha=255.

for the most part this doesn't matter one way or the other except when
we get to blending (not yet done for RgbaBitmaps, but coming soon) and
saving RgbaBitmap's to PNG files where it becomes blatantly obvious
when you have a bitmap with all/mostly alpha=0 pixels!
2023-03-21 16:55:57 -04:00
Gered 6a0be2756a add some useful rgba color constants
copied from the default VGA/EGA palette
2023-03-21 16:53:00 -04:00
Gered ec437974ee add RgbaBitmap::load_file 2023-03-21 15:40:31 -04:00
Gered 04f57cf8da convert graphics visual tests reference images to png
this just makes it a lot easier to open up in whatever graphics tool
is available during development
2023-03-21 15:25:25 -04:00
Gered b6e69ca084 allow png files to be loaded via IndexedBitmap::load_file 2023-03-21 15:23:47 -04:00
Gered 6829800caa organize test assets a little bit better 2023-03-21 15:09:47 -04:00
Gered 3d9d97db08 rename to avoid compiler warning
for now until we later fully implement this function and use these
arguments
2023-03-20 22:19:14 -04:00
Gered 11625f58a5 add png save tests 2023-03-20 22:18:15 -04:00
Gered a5c8af67ad set alpha component consistently with other colours during palette read
when reading palette files/streams, we set up the colour entries
using helper functions that automatically set an alpha component of 255.
however, we were first initializing the palette with 0 (alpha component
of 0 too).

this meant that if a palette of less than 256 colours was loaded, the
remaining entries (since Palette is always sized for 256 colours), were
black (0,0,0) with alpha components of 0.

this change makes all palette entries have a consistent alpha value
(which is never really used anyway ...) when loaded.
2023-03-20 22:18:02 -04:00
Gered 148a24ca42 implement png saving
note that we only allow RgbaBitmaps to save RGBA colour format pngs.
likewise, IndexedBitmaps can only save indexed-colour format pngs.
2023-03-20 21:47:02 -04:00
Gered ac4df9e8ed merge functionality of PixelDecoder and ScanlineBuffer together 2023-03-20 17:47:18 -04:00
Gered 48c694192b maybe improve png decoding, sorta, kinda, i guess? 2023-03-20 17:14:38 -04:00
Gered d02b81b1fb extra tests for other unsupported png scenarios 2023-03-20 12:06:10 -04:00
Gered 76d0289a0f add png loading tests 2023-03-20 12:02:55 -04:00
Gered 6e09c84c4a implement working filter-aware png scanline decoding
this is all gross at the moment, but it works. which is the goal right
now.
2023-03-19 22:55:46 -04:00
Gered eb5869b600 initial and semi-incomplete png loading support
- no filters other than filter 0 right now
- no png file saving
- inefficiencies
- maybe some bugs, not a full test suite yet
2023-03-16 21:20:43 -04:00
Gered 6de4bf3ef0 add temporary (and wasteful) methods to load gif/iff/pcx to RgbaBitmaps
temporary measure until i feel like making the existing loading process
for all of these able to handle variable pixel bit-depth destinations.
not super high on my priority list so this may not happen for a while.
2023-03-13 13:03:55 -04:00
Gered bc59442311 add method to convert an IndexedBitmap to an RgbaBitmap
doing the reverse is a fair bit more complicated, so we'll leave that
alone for now!
2023-03-13 13:02:21 -04:00
Gered 99de921f64 fix solid_blit pointer stuff
i did not read the doc comments for pointer methods and mistakenly
thought i needed to calculate raw byte offsets here, but actually it
works in units of size T (where T in our case is either u8 or u32)
2023-03-11 21:14:01 -05:00
Gered 2cf763bb73 add Standard implementation of SystemResources
this uses 32-bit colour graphics via RgbaBitmap
2023-03-11 21:03:57 -05:00
Gered 503f822a87 make Bitmap::new private to force creation via concrete aliased types 2023-03-11 17:24:53 -05:00
Gered c1dcc39bc1 set up visual comparison graphics tests for indexed+rgb versions
the rgb versions are not yet present, however
2023-03-11 17:15:53 -05:00
Gered 07f2b13f68 large amount of bitmap graphics rework
this is an unfortunately large commit. probably should've been broken
up into multiple smaller ones.

i decided to revert some earlier preparatory work i had done to organize
graphics functionality into two main streams: "indexed" and "rgb". this
was going to result in two completely different Bitmap structs which
were going to be largely similar and as i thought about it more, i
realized my earlier thinking that i wouldn't be able to generify the
Bitmap struct based on pixel-depth was actually not correct.

so, this commit re-works things significantly in a way which i think
is better but probably still not perfect. basically, we have one
Bitmap struct which provides a lot of generic functionality, but also
specialized implementations based on pixel-depth and this is now what is
separated out into graphics::bitmap::indexed and graphics::bitmap::rgb.

but the rest of the graphics functionality is not separated out by
module like this any longer.

note that i've still kept the GeneralBitmap trait and implementations.
i was originally thinking i could get rid of this since i'd now made
Bitmap generic over pixel-depth, but doing so would require me to
rename the common/general blit methods to avoid a name collision with
the specialized implementations (since they would both exist on the
same types now). and i did not like that. i dunno, maybe i will change
my mind later.
2023-03-11 16:58:13 -05:00
Gered 2b414072bc move RGB/RGBA colour related functions into common module
these are obviously useful to new 32-bit graphics functionality, but
they are also useful to indexed colour functionality such as palettes
and blendmaps.
2023-03-10 11:11:04 -05:00
Gered 06f055c042 fix compiler warning 2023-03-09 19:10:31 -05:00
Gered 2e57311fe0 try to clean up module 'use' stuff with new prelude modules
though i am not sure how good an idea my approach was with a bunch of
intermediate preludes. i was thinking it might be nice to be able to
only pick out the preludes that you wanted (if not all), but ... would
i ever really need to do that? somehow i am thinking, no, but i will
give it some more thought
2023-03-09 19:10:11 -05:00
Gered 75401cb5c7 move repeated 'PixelType' type constraints to new Pixel trait 2023-03-09 16:32:46 -05:00
Gered 986a2a9677 make fonts generic over GeneralBitmap types
this also includes a semi-important change where the existing
BitmaskCharacter draw implementation will now not draw anything if
FontRenderOpts::None is passed in, instead of just substituting color 0.

this probably makes more sense this way anyway
2023-03-09 16:20:44 -05:00
Gered 434bd6dbed maybe, sortof, clean up CustomMouseCursor and DefaultMouseCursorBitmaps
i like this a bit more, but this still feels a bit icky to me ... sortof
2023-03-09 15:14:38 -05:00
Gered f3d213130d revert hackfix in GeneralBlitMethod. fix CustomMouseCursor rendering
at this point i am 99% certain that the previous issues i was having
with making GeneralBlitMethod generic over the bitmap PixelType was
because i was trying to specify a constant PixelType value in generic
code (CustomMouseCursor).

whether this was actually the problem or not i think is besides the
point however because while thinking about this i suddenly realized this
was incorrect anyway!

making CustomMouseCursor generic via GeneralBitmap means that specifying
constant colours was not going to produce expected results (e.g. '255'
has a very different meaning for indexed colour rendering versus for
32-bit RGBA colour format).

so, CustomMouseCursor now figures out the correct transparent colour
to use from the DefaultMouseCursorBitmaps implementation.

this allows us to make GeneralBlitMethod be generic over a bitmap's
PixelType again and i'm sure we won't have that previous issue again as
long as we don't try to specify constant colour values in our generic
rendering code ... which we should never be doing anyway!
2023-03-09 14:51:01 -05:00
Gered 696ed0bfb3 rename "BasicImage" to "GeneralBitmap"
this feels like a much, much, much better name to me. not sure what i
was thinking before!
2023-03-09 11:57:07 -05:00
Gered 2c2cf9dacd remove now unnecessary 'todo' comment 2023-03-08 21:11:12 -05:00