slpctrl Posted January 29, 2009 Share Posted January 29, 2009 Hey guys, I was starting a project and I was wondering, how would I take a 1 pixel slice, say in the middle of an image and return the hex color for each pixel across? I'm thinking I need to use the function 'imagecolorat', but I'm just not sure how to go about this. Any help would be GREATLY appreciated, resources or anything that might be useful. Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/ Share on other sites More sharing options...
.josh Posted January 29, 2009 Share Posted January 29, 2009 look at this post. All you have to do is strip out the outer loop and conditions and stuff. Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749187 Share on other sites More sharing options...
slpctrl Posted January 29, 2009 Author Share Posted January 29, 2009 look at this post. All you have to do is strip out the outer loop and conditions and stuff. look at this post. All you have to do is strip out the outer loop and conditions and stuff. Thanks, I appreciate it. I don't want to sound ungreatful, because the code is very very helpful to me but I'd also like, if you had available, maybe other resources to teach me how to do it because I want to code it from scratch so that I can understand what I'm doing better. Thanks . Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749198 Share on other sites More sharing options...
corbin Posted January 29, 2009 Share Posted January 29, 2009 So you want him to tell you how to do it, but you want to do it from scratch? Well, if you want to start from the basics: http://php.net/gd Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749209 Share on other sites More sharing options...
.josh Posted January 29, 2009 Share Posted January 29, 2009 Well what are you expecting, a tutorial on how to pick a specific pixel row in an image file, and loop to the end of it? I doubt you're going to find a tutorial that specific. The post I pointed you to does exactly what you want, only more. It just loops through all of the rows and does some condition the other guy needs, that has nothing to do with what you want. As said, all you need to do is remove the outer for loop and use the specific row number you want, and cut out the condition, since you don't need it. I don't think it will get any more specific for you. There is plenty of comments in the code, and you can also go to the manual and look at each of those GD functions to read up on what all they actually do. You said you don't want to sound ungrateful, but I mean come on, I'm handing something to you on a silver platter. What more do you want? Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749211 Share on other sites More sharing options...
slpctrl Posted January 29, 2009 Author Share Posted January 29, 2009 So you want him to tell you how to do it, but you want to do it from scratch? Well, if you want to start from the basics: http://php.net/gd Did I ever once say I want someone to tell me how to do it? It was really a request for a resource to teach me how to do it, I've already read through every function of the GD library. I pretty much know it's the function imagecolorat that's gonna really get me through what I'm trying to do, I'm just not 100% sure on how to use it to achieve what I want. Well what are you expecting, a tutorial on how to pick a specific pixel row in an image file, and loop to the end of it? I doubt you're going to find a tutorial that specific. The post I pointed you to does exactly what you want, only more. It just loops through all of the rows and does some condition the other guy needs, that has nothing to do with what you want. As said, all you need to do is remove the outer for loop and use the specific row number you want, and cut out the condition, since you don't need it. I don't think it will get any more specific for you. There is plenty of comments in the code, and you can also go to the manual and look at each of those GD functions to read up on what all they actually do. You said you don't want to sound ungrateful, but I mean come on, I'm handing something to you on a silver platter. What more do you want? Alright then; I really appreciate it . Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749212 Share on other sites More sharing options...
slpctrl Posted January 29, 2009 Author Share Posted January 29, 2009 One more thing(I'm not very good with the GD library at all): I'm coding a barcode reader, it's gonna take the image and return the barcode number. Since I'm only dealing with black and transparent (or white), would that make a difference? ??? Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749215 Share on other sites More sharing options...
.josh Posted January 29, 2009 Share Posted January 29, 2009 well if you're trying to figure out which pixels are black and which ones are white, then coincidentally, the condition in that post will actually be of some use to you. Quote Link to comment https://forums.phpfreaks.com/topic/142900-help-with-the-gd-library/#findComment-749221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.