Jump to content


Photo

[Solved] Loop through image and record each pixel color


  • Please log in to reply
5 replies to this topic

#1 xxOrpheus

xxOrpheus
  • Members
  • 126 posts

Posted 22 October 2011 - 04:31 AM

<allcapsrage>
OH MAH GAAWDDDDD PLEASE HELP!!!1111
</allcapsrage>

I'm trying to loop through each pixel on an image and record it's color, but the loop just won't run!!!!!11111 :evil:

My current code:

Convert:
	pToken := Gdip_Startup() ;Start GDIP
	pBitmap := Gdip_CreateBitmapFromFile(image) ;Create a bitmap from a file (jpg, png, gif ...)
	Width := Gdip_GetImageWidth(pBitmap) ;Get image width
	Height := Gdip_GetImageHeight(pBitmap) ;Get image height
	Loop Width {
		x := x + 1
		Loop Height {
			y := y + 1
			dec := Gdip_GetPixel(pBitMap, %x%, %y%) ;Get the pixel color
			colors .= DEC2HEX(dec, "true") ;Add it to the variable
		}
	}
	Gdip_DisposeImage(pBitmap) ;Dispose of the image
	Gdip_Shutdown(pToken) ;Shutdown GDIP
return

EDIT:
AHHHH
Fixed :evil: :evil: :evil:

Didn't have %'s around my variables in the loop .....

#2 Leef_me

Leef_me
  • Moderators
  • 7704 posts

Posted 22 October 2011 - 06:01 AM

Please, when you find your solution without help, please either respond to you own post and explain, or (preferably) mark you thread as [solved].

Toning down the language would be nice too.

Thanks.

#3 xxOrpheus

xxOrpheus
  • Members
  • 126 posts

Posted 22 October 2011 - 06:32 AM

Please, when you find your solution without help, please either respond to you own post and explain, or (preferably) mark you thread as [solved].

Toning down the language would be nice too.

Thanks.

I apologize, I didn't think it really mattered, considering I didn't actually swear :O

I'll mark as solved now.

#4 tomoe_uehara

tomoe_uehara
  • Members
  • 2077 posts

Posted 22 October 2011 - 03:38 PM

<allcapsrage>
OH MAH GAAWDDDDD PLEASE HELP!!!1111
</allcapsrage>

Jiahahahaha... If you're in desperate for help, just try the IRC.
Posted Image

#5 thesoupmeat

thesoupmeat
  • Members
  • 188 posts

Posted 23 July 2012 - 11:08 PM

how do i try the IRC??

#6 Leef_me

Leef_me
  • Moderators
  • 7704 posts

Posted 24 July 2012 - 12:09 AM

how do i try the IRC??

Very top post in the Support forum.