Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - How do I invert colours? | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1941/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
I want to draw an inverted-colour version of an image, how can I do that? I normally just use BitBlt to draw it. (I'd prefer not having to modify the image itself.) | |||
Dish Spiny Level: 38 Posts: 157/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
If you're doing opaque blits... you might be able to perform this with 2 seperate BitBlt calls.. first using WHITENESS and next using SRCINVERT (instead of a single call using SRCCOPY). I'm not sure how you'd go about it if you're doing transparent blits... at least... not without inverting the actual image (or making a copy and inverting the copy). |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1942/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
I'm not drawing transparent, but I do draw transparent images on top of them, if that matters. Could you elaborate just what you mean? | |||
Dish Spiny Level: 38 Posts: 158/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
Yeah drawing on top won't matter... as long as the opaque image is drawn first. typical opaque blit: BitBlt( destDC, destX, destY, wd, ht, srcDC, srcX, srcY, SRCCOPY ); inverted opaque blit: BitBlt( destDC, destX, destY, wd, ht, srcDC, srcX, srcY, WHITENESS ); BitBlt( destDC, destX, destY, wd, ht, srcDC, srcX, srcY, SRCINVERT ); I haven't tested this but it seems like it would work. I'm unsure how it would look in VB, but I'm sure the params are the same (or similar). |
|||
Gavin Fuzzy Rhinoceruses don't play games. They fucking charge your ass. Level: 43 Posts: 294/799 EXP: 551711 For next: 13335 Since: 03-15-04 From: IL, USA Since last post: 13 hours Last activity: 13 hours |
| ||
Originally posted by Disch invert picMain's colors. are you sure Disch? i thought you would just use MERGEPAINT, then SRCAND to get a trainsparent image.. maybe i'm not understanding exactly what he was looking for... |
|||
Dish Spiny Level: 38 Posts: 159/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
Originally posted by Gavininvert picMain's colors. Well he said he wanted to just to an inverted blit, without changing the source image. The blit you gave looks like it would invert the source image (assuming picMain.hDC has the source image) I guess DSTINVERT would work too... but only after the image is copied with SRCCOPY. Almost any way you slice it.... it's going to take 2 blits... which 2 you use could be different though: SRCCOPY, then DSTINVERT WHITENESS, then SRCINVERT BLACKNESS, then MERGEPAINT or you could also load a solid white brush into the destination DC and blit with PATINVERT. The PATINVERT route would probably be the fastest since it only involves one blit. After that I would assume the WHITENESS/BLACKNESS routes would be a little faster than the remaining route... but that's just a guess. The MERGEPAINT and SRCAND combo doesn't look like it would work to me... it would make some interesting results, but it wouldn't be color inversion. For an explaination of how the color is found for each of these blit methods (think I have all these right, you may want to doublecheck though): SRCCOPY: dest = src DSTINVERT: dest = dest ^ 0xFFFFFFFF WHITENESS: dest = 0xFFFFFFFF SRCINVERT: dest = dest ^ src BLACKNESS: dest = 0 MERGEPAINT: dest = dest | (src ^ 0xFFFFFFFF) SRCAND: dest = dest & src To do an inverted blit, you ultimately want: dest = src ^ 0xFFFFFFFF I'm pretty sure the combos I mentioned will get you that result. MERGEPAINT and SRCAND will give you something funky though... like: dest = (dest | (src ^ 0xFFFFFFFF)) & src |
|||
sloat Level: 16 Posts: 8/85 EXP: 18044 For next: 2212 Since: 05-21-04 From: South Central Delaware Since last post: 19 days Last activity: 5 hours |
| ||
You could also use PatBlt to draw an inverted rect over a device context if it applies better. It's sorta the same as BitBlt, but doesn't take any source bitmaps. For more info: MSDN PatBlt (edited by sloat on 11-02-04 12:46 PM) |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1943/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Cool, blackness and mergepaint worked great. [edit] Private Sub optTools_Click(Index As Integer) DrawMode = Index End Sub If Index is 0, I get an Invalid Property Value error. DrawMode is a public integer in a module, and optTools is a control array of option buttons. Sure, NOW you tell me that DrawMode is a reserved keyword. *kicks VB* (edited by HyperHacker on 11-02-04 01:03 PM) (edited by HyperHacker on 11-02-04 01:09 PM) |
|||
Dish Spiny Level: 38 Posts: 161/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
*Disch kicks self upon further research... I see there's a NOTSRCCOPY option which does a normal inverted blit. So you could replace the 2 bitblt calls with a single one using NOTSRCCOPY. I must have just missed that one before or something... egads. |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 1947/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Hey, that works too. |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - How do I invert colours? | | | |