Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > how to change colors in graphic in VB 6 ???


Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2004, 05:40 AM
Patxi Patxi is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Question how to change colors in graphic in VB 6 ???


hello,

iīve got a problem in my vb6 control with a graphic and really donīt know how to do this.

i would like to implement a car driver graphic (pixel or vector, it depends whatīs easier) where i would like to change dynamically the color of the head, chest, left leg,...

a sample graphic you can find here:
http://www.euroncap.com/assets/graph...ont_driver.gif

i tired to do it with alpha channels and masks, but couldnīt find out how to do it.
an other way i was thinking if itīs easier to use a vektor graphic? but how would this work?

i need to have about 3-4 graphics like this to implement, so it would be nice if the solution would be quite simple.

has anybody experience or an idee with this?

thanks a lot,

patxi
Reply With Quote
  #2  
Old 02-19-2004, 07:37 AM
GavinO's Avatar
GavinO GavinO is offline
Coder of Fortune

Retired Leader
* Expert *
 
Join Date: Dec 2002
Location: Troy, NY USA
Posts: 3,120
Default

If you create mask images for each region of the image that you want to color seperately, you can use normal and/or masking techniques. The basic idea is to lay down a block of color on a scratch surface, and AND it with a mask that has white where you want the color. You AND the target with the inverse of this mask, and then OR the scratch surface to the image. Best method is usually BitBlt using the appropriate RasterOp constant.
__________________
-- The Gavster
Like to IRC? Try irc.randomirc.com
GavServer
Reply With Quote
  #3  
Old 02-19-2004, 12:59 PM
Patxi Patxi is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Default

Quote:
Originally Posted by GavinO
If you create mask images for each region of the image that you want to color seperately, you can use normal and/or masking techniques. The basic idea is to lay down a block of color on a scratch surface, and AND it with a mask that has white where you want the color. You AND the target with the inverse of this mask, and then OR the scratch surface to the image. Best method is usually BitBlt using the appropriate RasterOp constant.



hey thanks,

now i know, why iīm called a "Newcomer" and GavinO is called an "Expert" !

sound quite interesting what you have written. but sounds quite complicated as well (for me).
i think i have to play around with the link you gave & read and read your message again...

thanks, but iīm not sure if i will get this...

at the link you gave, the say something about a rectangle:

"The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context."

does it mean that i will have problems if i have oval mask (head ...)?

thx,

Patxi
Reply With Quote
  #4  
Old 02-19-2004, 01:30 PM
GavinO's Avatar
GavinO GavinO is offline
Coder of Fortune

Retired Leader
* Expert *
 
Join Date: Dec 2002
Location: Troy, NY USA
Posts: 3,120
Default

The reason that you create the mask is to allow you to fill any shape using a rectangular blit area. Only the pixels on the mask that are white will be filled with the color, while the black ones will be left as they are (I am refering to the mask applied to the colored rectangle; the process is opposite for the one applied to the destination image). I've attached an image that sort of explains the process.
Attached Images
File Type: bmp maskblit.bmp (195.4 KB, 5 views)
__________________
-- The Gavster
Like to IRC? Try irc.randomirc.com
GavServer

Last edited by GavinO; 02-19-2004 at 01:56 PM. Reason: Corrected error in image
Reply With Quote
  #5  
Old 02-20-2004, 01:15 PM
Patxi Patxi is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Thumbs up

Hello GavinO,

thanks for all. i understood what you meant now.

i found some classes at vbAccelerator and used a sample from there ( http://www.vbaccelerator.com/home/VB...ng/article.asp ).

itīs a bit easier for me to write the code. the prinziples are based on the stuff you tried to explain me.

thx,

Patxi
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HowTo: change system colors ??? Dolptrmn Interface and Graphics 1 11-17-2003 04:57 PM
How to change HTML Code In VB? vikassethi General 4 02-11-2003 08:29 AM
QB to VB Conversion - By AIO BillSoo Tutors' Corner 0 08-06-2002 11:37 AM
why not use flash? wild wolf Game Programming 24 01-29-2002 11:04 AM
Help how you change the system/clock time in vb 60 visualbasic700e General 1 11-05-2000 08:25 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->