473,408 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Getting pixel colour in C

Hello,

I haven't asked If I wasn't really confused :)

OK, so I am just beginning SDL programming in C, and I was running fine, until I tried getting a pixel colour.
Basically, I am trying to run the code from this page:
http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access

This is the cut down version of my code:

Expand|Select|Wrap|Line Numbers
  1. snip
  2. SDL_Color GetPixel ( SDL_Surface* Screen , int x , int y ) ; //define struct
  3. snip
  4. int main( int argc, char* argv[] )
  5. {
  6.     SDL_Init( SDL_INIT_VIDEO );
  7.     SDL_Surface* Screen =  SDL_SetVideoMode( width, height , 32, DL_HWSURFACE | SDL_DOUBLEBUF ) ; //use Screen as surface
  8. snip
  9. curr_col = GetPixel(Screen, ant[1], ant[2]); //DOESN'T WORK! this is line 36
  10. snip
  11. boxRGBA(Screen,
  12.     ant[1], ant[2],
  13.     ant[3], ant[4],
  14.     ant[5], ant[6], ant[7], ant[8]); //DOES WORK
  15. snip
gcc output:
Expand|Select|Wrap|Line Numbers
  1. test.c: In function ‘main’:
  2. test.c:36: error: incompatible types in assignment
  3. test.c:38: error: expected expression before ‘{’ token
PS! I believe the line 38 error comes from the faulty(?) line 36, since it's a simple if cond.

Any help would be much appreciated :)
Thank you.
Dec 19 '07 #1
2 2080
weaknessforcats
9,208 Expert Mod 8TB
It looks like the return type of GetPixel() is not the same as the type of curr_col so the compiler can't make the assignment.
Dec 19 '07 #2
Yes, that was it.
I'm surprised I didn't think about it :(

But still, a big thanks.
Dec 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Derek Scollon | last post by:
I'm using PHP4.2.2 with gd on a Linux platform and am having difficulty in solving a little problem despite going through the definitions of the various image functions. If you load a...
3
by: Weston C | last post by:
Is there any way to use javascript to pull the color of the pixel under the mouse pointer off the page? Thanks, Weston ~==~ http://weston.canncentral.org/ weston8cann8central.org (remove...
7
by: walter.alex | last post by:
November 16 2005 -- The recent launch of the new 5 year advertising solution from MillionPixelClick.com means the pixel advertising craze will continue unabated. Selling advertising space by the...
3
by: Mark Ingram | last post by:
Hi, ive got an imagine in a PictureBox, and would like to get the colour of the pixel when the mouse is over the control. From what ive (briefly) seen, there is no way to do this directly in C# and...
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
4
by: ChillUmesh | last post by:
can we do a program to change colour of each pixel of the form. If so can anyone help me in this. thnx.....
4
by: Johny | last post by:
I use PIL to write some text to a picture.The text must be seen wery clearly. I write the text to different pictures but to the same position. As pictures maybe different, colour, in the...
3
by: HackerOverload | last post by:
Okay, well I am trying to detect when a program is done, by detecting the colour change of the pixels. See, when the program is done, it has gets a big blue button at the bottom to exit it. And i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.