Computer Science Canada Bit shifting and Images |
Author: | copthesaint [ Tue May 08, 2012 10:47 pm ] | ||
Post subject: | Bit shifting and Images | ||
I am trying getting the bit values of any image and Im trying to obtain the R,G,B values. the values obtained from takePic are defined as BGRB, GRBG, RBGR generally. If for example one pixel values were 255,128,60,55 then the result of that one value from takePic would be (255 * 2^0 + 128 * 2 ^ 8 + 60 * 2 ^ 16 + 55* 2 ^ 24) which would = 1853424126 When you use take pic it gives you the bit value but not the value of the colors themselves. Can someone help me with this? I want to get back the values of RGB from the bit value.
|
Author: | Raknarg [ Wed May 09, 2012 9:02 am ] |
Post subject: | RE:Bit shifting and Images |
RGB.GetColour (x : int, var r, g, b : real) I think that does what you're looking for |
Author: | copthesaint [ Wed May 09, 2012 10:42 am ] | ||||
Post subject: | RE:Bit shifting and Images | ||||
No, I already know of it, I want to know how I can use the bitwise operators to get the colors of the image. When you use takepic (x1,y1,x2,y2 : int , var b : array 1 .. * of int) It sets every color value of the image in the buffer array. I am trying to figure out how to get the rgb values from the color numbers. the first few values in the buffer are identities and at 18, the numbers are in a sence an index to a color. Edit: Currently I have my picture displaying after getting the values, I changed line 48:
To
because it made more sence being there are 256 avalible colors however the image gets black lines down the middle now... |
Author: | Raknarg [ Wed May 09, 2012 1:28 pm ] |
Post subject: | RE:Bit shifting and Images |
Sorry, thats all I have ![]() |
Author: | copthesaint [ Wed May 09, 2012 1:36 pm ] |
Post subject: | RE:Bit shifting and Images |
I am making a new draw module (using turing predefines) to see how well it will work, I want to be able to rotate images as 3D objects easier in turing, however I didnt want to use RGB.SetColor since it takes up a freaking huge amount of time and you can only set at most 1000 colors, I know that 256*256*256 colors will be enough for me though ![]() If you want to know the difference between turing draw module (8bit) and my draw module I hope to finish (24bit) glimpse at this wiki http://en.wikipedia.org/wiki/Color_depth I still cant figure out how to properly get the colors from the image... |
Author: | Amarylis [ Wed May 09, 2012 8:37 pm ] | ||
Post subject: | RE:Bit shifting and Images | ||
I wish you luck in your quest... Also, a personal request, if at all possible, could you make the drawpic work with 2D arrays as opposed to 1D? I find that messing with pixel data is a lot simpler when you can use coordinates for them ![]() I saw this a while ago and I made a procedure in my Draw module that would work as what I mentioned above, though it's really just a bit of a cheap trick...
Edit: My suggestion for you is to make the class Layer be a module instead, so that way you dont have to create an object for it every time you want to draw an image |
Author: | copthesaint [ Wed May 09, 2012 10:30 pm ] | ||
Post subject: | Re: Bit shifting and Images | ||
The layer class is purposely a class for the render module I will make so then individual drawings can be done to sperate layers, Making fills and other future implements much easier. trust me, it is better this way ![]()
I am doing everything specifically for what I have in mind for the future. Just sometimes, like now for instance, I run into a road block. |
Author: | copthesaint [ Thu May 10, 2012 10:39 am ] |
Post subject: | RE:Bit shifting and Images |
Bump ~ After spending the time to write everything on paper and reading more, I have come up with the solution on my own. |
Author: | Amarylis [ Thu May 10, 2012 12:24 pm ] |
Post subject: | RE:Bit shifting and Images |
Oh? What did you come up with? |
Author: | copthesaint [ Thu May 10, 2012 1:28 pm ] | ||
Post subject: | Re: Bit shifting and Images | ||
It took a while to figure out how to correctly do this, but here is what I implimented into my module:
|