News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Creating a bitmap programmatically: how?

Started by NoCforMe, January 17, 2024, 08:37:55 AM

Previous topic - Next topic

NoCforMe

#30
BTW, if you ever wondered what letters look like up close, here they are. (Bodoni Book BT, size 48**, ClearType quality.) Interesting to see how the characters are anti-aliased.


** "Logical" size, not point size. 36 points.
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on January 20, 2024, 07:16:37 AMI find it very annoying when folks make comments but they obviously haven't read what I've written!

Yeah, I know that feeling. There are people who don't even open attachments carefully prepared by members of this forum :cool:

QuoteWith GDI, remember, not GDI+.

You would see much better anti-aliasing if you could overcome this limitation.

Re converting bitmaps to 256 colours: Probably there are some API calls around, probably you'll find something on StackOverflow or CodeProject. The main stumbling block here is that 32-bit bitmaps don't need a palette, while 256 colour bitmaps do require one. And you need to transform a 32-bit pixels (unused alpha, R, G, B) into a one byte palette index. That means you have to squeeze 4 Gigabytes of colours into one 256 bit palette value. PaintShop, for example, offers several algorithms, see below. It's not trivial.


P.S.: As you might have noticed, I am using words, not code, to communicate with you.

NoCforMe

Quote from: jj2007 on January 20, 2024, 10:04:49 AM
Quote from: NoCforMe on January 20, 2024, 07:16:37 AMI find it very annoying when folks make comments but they obviously haven't read what I've written!

Yeah, I know that feeling. There are people who don't even open attachments carefully prepared by members of this forum :cool:
Yeah, except that the code was unasked for. I asked for apples and got oranges.

Quote
QuoteWith GDI, remember, not GDI+.
You would see much better anti-aliasing if you could overcome this limitation.
Well, that would be an interesting experiment. Maybe after I get this thing put together I'll try GDI+ and see what differences there are.

QuoteRe converting bitmaps to 256 colours: Probably there are some API calls around, probably you'll find something on StackOverflow or CodeProject. The main stumbling block here is that 32-bit bitmaps don't need a palette, while 256 colour bitmaps do require one. And you need to transform a 32-bit pixels (unused alpha, R, G, B) into a one byte palette index. That means you have to squeeze 4 Gigabytes of colours into one 256 bit palette value. PaintShop, for example, offers several algorithms, see below. It's not trivial.


As I said, not being able to use an alternative format isn't a show-stopper, but it's disappointing. I might root around some after getting this working. Some of what I've read implies that Windows might be able to synthesize a palette in some cases. Though as you say it isn't trivial and I wouldn't be so sure about the quality of the down-conversion.

Pretty sure 32-bit images are 16+ million colors, no? Because as you say the alpha channel is unused, so isn't it 256 x 256 x 256?

Yep, I'm very familiar with that reduce-#-of-colors dialog. Have used it hundreds of times.

QuoteP.S.: As you might have noticed, I am using words, not code, to communicate with you.
That, my friend, is appreciated.
Assembly language programming should be fun. That's why I do it.

_japheth

Quote from: NoCforMe on January 20, 2024, 12:42:03 PMAs I said, not being able to use an alternative format isn't a show-stopper, but it's disappointing. I might root around some after getting this working.

There might exist multiple ways to achieve this. One way that I know of is using CreateDIBSection() - because I once created a monochrome bitmap of the screen with it. You have to carefully setup the BITMAPINFO structure that this function needs as input. For my monochrome picture I just supplied black and white colors, of course.

Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

TimoVJL

QuoteThe best shoot is probably to convert to the old Netscape palette, which is a color palette with 216 colors, which has 6 levels (00H, 33H, 66H, 99H, CCH and FFH) for each color (R, G, B). There are many links like this one: http://www.webmaster.crevier.org/tags/palette.html , which describes this palette.
Fixed color palette
May the source be with you

NoCforMe

#35
OK, here it is, the finished product, let's call it v1.0. Creates a 32 BPP BMP. Please play around with it, let me know whatcha think, if anything. (Hopefully I didn't forget to include any files like I usually do!)

Try the font quality combobox: most dramatic difference is selecting "non-antialiased".
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: TimoVJL on January 20, 2024, 08:28:14 PM
QuoteThe best shoot is probably to convert to the old Netscape palette, which is a color palette with 216 colors, which has 6 levels (00H, 33H, 66H, 99H, CCH and FFH) for each color (R, G, B). There are many links like this one: http://www.webmaster.crevier.org/tags/palette.html , which describes this palette.
Fixed color palette

I like my "universal palette" better. Totally user-defined. A little bit of this, a little bit of that.

Assembly language programming should be fun. That's why I do it.