News:

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

Main Menu

Has anyone used gdiplus to change hue?

Started by zedd151, April 11, 2025, 08:15:16 AM

Previous topic - Next topic

NoCforMe

@Zedd: Try the color swapper on any regular JPG picture; it works, but the change is usually very subtle, even hard to see.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 13, 2025, 06:02:01 AM
Quote from: zedd151 on April 13, 2025, 05:44:57 AMI only tested it with bitmaps. :rolleyes:
Works a charm with 32 bit .pngs
A .png is a bitmap.
It'll work correctly with any 32 BPP image format.
QuoteIs it ARGB or RGBA? I have seen both used, and that is confusing.
I'd say ARGB, based on the memory layout of a pixel (I had to draw this for myself to keep things straight):

You cannot view this attachment.
Fair enough. But during my research I kept seeing RGBA all over the place, so naturally that's what I thought was most proper.  :rolleyes:

In retrospect ARGB sounds more likely upon thinking about it.

zedd151

Quote from: NoCforMe on April 13, 2025, 06:11:21 AM@Zedd: Try the color swapper on any regular JPG picture; it works, but the change is usually very subtle, even hard to see.
Okay, gimme about an hour. It's time to feed, then walk, the doggies.

guga

Hi David

these are the ones inside the comments.

Hexadecimal in RosAsm can use the ending "h" or not. Hexadecimals are represented by 1 leading 0 ate the beginning. It also can contains separators "_" for better reading if needed. But, "x" is not allowed, since it is used for mathematical expressions.
Ex:
0123FA25D
can also written as:
0123FA25Dh - similar to masm syntax, i presume
0123F_A25Dh - similar to masm syntax, i presume (except for the separator)
0123F_A25D
0_123F_A25D
0_123F_A25Dh - similar to masm syntax, i presume (except for the separator)


Separators do nothing at all, unless make the numbers (or labels, variables names etc) better to read.

Decimals always starts from 0 to 9. So, not changes here for masm syntax

Binary always starts with 2 leading 0. Also may contains optional identification "b" and optional separator "_"

Ex:
The number 196865 (in decimal), can be represented in binary as:
00__0000_0011__0000_0001__0000_0001
00__0000_0011__0000_0001__0000_0001b
00000000110000000100000001b (less readable) - similar to masm syntax, i presume
00110000000100000001b (less readable) - similar to masm syntax, i presume
00000000110000000100000001 (less readable)
00110000000100000001 (less readable)

Personally, i prefer without the ending identificators and using separators "_" when is better to read.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

zedd151

Quote from: NoCforMe on April 13, 2025, 06:11:21 AM@Zedd: Try the color swapper on any regular JPG picture; it works, but the change is usually very subtle, even hard to see.


NoCforMe

OK, those artifacts are because I'm ASS-U-Ming a 32bpp image where it's actually 24bpp.
Smarter manipulation code would take care of this.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: guga on April 13, 2025, 06:37:57 AMHexadecimal in RosAsm can use the ending "h" or not. Hexadecimals are represented by 1 leading 0 ate the beginning. It also can contains separators "_" for better reading if needed. But, "x" is not allowed, since it is used for mathematical expressions.
Ex:
0123FA25D
can also written as:
0123FA25Dh - similar to masm syntax, i presume
0123F_A25Dh - similar to masm syntax, i presume (except for the separator)
0123F_A25D
0_123F_A25D
0_123F_A25Dh - similar to masm syntax, i presume (except for the separator)
Sorry, too weird for most of us here.
"Except for the separator": that's the problem.
I won't bother even trying to decipher or convert such representations.
Life's too short.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 13, 2025, 07:23:24 AMOK, those artifacts are because I'm ASS-U-Ming a 32bpp image where it's actually 24bpp.
Ah, okay. So the present code only works for 32bpp... got it.

NoCforMe

Quote from: zedd151 on April 13, 2025, 07:27:41 AM
Quote from: NoCforMe on April 13, 2025, 07:23:24 AMOK, those artifacts are because I'm ASS-U-Ming a 32bpp image where it's actually 24bpp.
Ah, okay. So the present code only works for 32bpp... got it.
Yes. Take a look at the pixel-changing code I posted.
It would take a lot more checking (on the bitmap format) and branching in that code to handle all those other formats.
Could be done, of course; I just wanted to throw together a small demo to show how it might work.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 13, 2025, 07:35:55 AMIt would take a lot more checking (on the bitmap format) and branching in that code to handle all those other formats.
Could be done, of course; I just wanted to throw together a small demo to show how it might work.
No thats fine. I might even play with the code a bit,  at least to cover 24bpp even if it is a seperate program from the 32bpp version.

NoCforMe

If you wanted to extend my program, you could look for the pixel format value of PixelFormat24bppRGB in the color-swapping code, and branch to a new section where you work on 24-bit pixels.

A little more complicated, as you'll need to read 3 bytes at a time, but still do-able. (You could use the same swapping code, just change the loop to read 3 bytes instead of a DWORD per pixel.)
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on April 13, 2025, 07:56:10 AMIf you wanted to extend my program, you could look for the pixel format value of PixelFormat24bppRGB in the color-swapping code, and branch to a new section where you work on 24-bit pixels.

A little more complicated, as you'll need to read 3 bytes at a time, but still do-able. (You could use the same swapping code, just change the loop to read 3 bytes instead of a DWORD per pixel.)
That's what I had in mind. At least something similar.  :thumbsup:

Now if I can put all of this aside long enough to finish my frigging game (Connect 4), I'll be as happy as a clam.  :joking:

All of these different ways to work with graphics is kind of addicting, always wanting more tools for the toolbox.

guga

Quote from: NoCforMe on April 13, 2025, 07:25:27 AM
Quote from: guga on April 13, 2025, 06:37:57 AMHexadecimal in RosAsm can use the ending "h" or not. Hexadecimals are represented by 1 leading 0 ate the beginning. It also can contains separators "_" for better reading if needed. But, "x" is not allowed, since it is used for mathematical expressions.
Ex:
0123FA25D
can also written as:
0123FA25Dh - similar to masm syntax, i presume
0123F_A25Dh - similar to masm syntax, i presume (except for the separator)
0123F_A25D
0_123F_A25D
0_123F_A25Dh - similar to masm syntax, i presume (except for the separator)
Sorry, too weird for most of us here.
"Except for the separator": that's the problem.
I won't bother even trying to decipher or convert such representations.
Life's too short.

I´ll try to write some basics translator in time. What´s the proper syntax for masm, then ? Only 0123FA25Dh, right ? Or there are other fixed tokens/syntax ?
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

zedd151

You only need the leading 0, if the first hex digit is A,B,C,D,E or F.
In your 0123FA25Dh
While it doesn't hurt to leave it there, normally it's not done like that.
Ought to be
123FA25Dh

Conversely:
ABCDEF01h would need the leading zero: 0ABCDEF01h else the assembler will assume it's a variable name even with the trailing h.





NoCforMe

Quote from: guga on April 13, 2025, 08:03:48 AMWhat´s the proper syntax for masm, then ? Only 0123FA25Dh, right ?
Decimal: just like anywhere else. (No "d" required.)
Hex: XXXXXh (must put in a leading zero if the first digit is A-F)
Binary: XXXXXb

Symbolic constants:
name EQU value

Data declarations:
name, optional  DB/DW/DD/DQ value(s)

Structure definition:
name    STRUCT
data declaration
data declaration
data declaration
   . . .
name    ENDS

Structure declaration:

name, optional  struct name <value(s), optional>
(angle brackets at end required)

That's it.
MASM keywords are case-insensitive; names aren't, unless an option is set to make them so.

(hopefully my nomenclature is clear)
Assembly language programming should be fun. That's why I do it.