Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

RGB separation

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-28-2007, 03:42 PM
Senior Member
 
Join Date: Apr 2007
Location: Kindred,ND
Posts: 122
Awards Showcase
Beta Tester 
Total Awards: 1
Default RGB separation

How do you separate the RGB from the number you get from getpixel. Is it done bitwise?
Reply With Quote
  #2 (permalink)  
Old 09-28-2007, 04:12 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hi bdiscount,

since there is no build-in feature for that, you have to do this manually with an own sub. You can use something like this:
Code:
Sub Globals
    red = 
0
    green = 
0
    black = 
0    
End Sub

Sub App_Start
    ...
    Color2RGB(bitmap1.GetPixel1(w,h))
    ...        
End Sub

Sub Color2RGB(color)
    colorNum = color + 
16777216
    red = 
Int(colorNum / 65536)        
    green = 
Int((colorNum - red * 65536) / 256)    
    black = colorNum - red * 
65536 - green * 256
End Sub
specci48
Reply With Quote
  #3 (permalink)  
Old 09-28-2007, 05:03 PM
Senior Member
 
Join Date: Apr 2007
Location: Kindred,ND
Posts: 122
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks specci48 I will try and incorporate it in my program.
Reply With Quote
  #4 (permalink)  
Old 09-28-2007, 06:49 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,313
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Just a minor rectification...
It's Red, Green, Blue (not Black)
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
B4PPC DLL Version Listing - B4Android DLL Version Listing
Reply With Quote
  #5 (permalink)  
Old 09-28-2007, 09:15 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 162
Default Explain, please...

Specci, what purpose does this serve:

Code:
colorNum = color + 16777216

Gary
Reply With Quote
  #6 (permalink)  
Old 09-28-2007, 09:40 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,313
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by specci48 View Post
Hi bdiscount,


Color2RGB(bitmap1.GetPixel1(w,h))
This calls the Clor2RGB sub passing the pixel(x,y) color value

Quote:

Sub Color2RGB(color)
colorNum = color + 16777216
red = Int(colorNum / 65536)
green = Int((colorNum - red * 65536) / 256)
black = colorNum - red * 65536 - green * 256
End Sub[/code]
Color2RGB takes the color value obtained from the pixel and converts it to an RGB value....

In the desktop, RGB has an extra value (chanel) Alpha (opacity), so it becomes ARGB... The 16777216 I'm gessing is to workaround this issue, asuming the full opacity value...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
B4PPC DLL Version Listing - B4Android DLL Version Listing
Reply With Quote
  #7 (permalink)  
Old 09-29-2007, 11:39 AM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default



... translation error ... keep the blue and cancel the black ...

Quote:
Originally Posted by willisgt View Post
Specci, what purpose does this serve:

Code:
colorNum = color + 16777216
This changes the original (negative) value into a positive format. If you code this

Code:
a = Rgb(0,0,0)
b = Rgb(
255,255,255)
a gets the value -16777216 and b gets the value -1.


specci48
Reply With Quote
  #8 (permalink)  
Old 10-01-2007, 12:11 AM
Senior Member
 
Join Date: Apr 2007
Location: Kindred,ND
Posts: 122
Awards Showcase
Beta Tester 
Total Awards: 1
Default

specci
your formula doesn't give me the correct rgb
I have a grey r=192 g = 192 b = 192

when I get pixel I get 3749946 on the device (only place I work.) 3749946/65536 =57.219 (red)
3749946 + 16777216 = 20527162 / 65536 = 313.219(red)

Have got it wrong?
Reply With Quote
  #9 (permalink)  
Old 10-01-2007, 04:39 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Since Erel has confirmed this code to be correct (http://www.basic4ppc.com/forum/showt...ighlight=green) I don't know where you are going wrong...

What device are you using? Can you post a small example?


specci48
Reply With Quote
  #10 (permalink)  
Old 10-01-2007, 05:14 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by bdiscount View Post
Have got it wrong?
Have you missed a minus sign?

-3749946 gives R=198, G=199, B=198, which could be a correct approximation for R=192, G=192, B=192 as your device probably only supports something like 64K colours rather than the full 8bits on each colour.

Last edited by agraham : 10-01-2007 at 05:28 PM.
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


All times are GMT. The time now is 10:12 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0