Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To get rgb values of each pixel
Message
From
04/01/2009 10:46:39
 
 
To
04/01/2009 09:20:12
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01370879
Message ID:
01370886
Views:
18
>i have to do the following
>
>1. i have a picture stored on my harddisk let us say 250 X 250 or 100 x 100 pixels ( it will always be a square)
>2. i need to capture each pixel in a table of a similar size (in hex, rgb or cmyk, it does not matter)
>
>so let us assume the table has the following fields
>
>P1, P2, P3 .... P100 with a 100 rows (c 12)
>then
>
>P1 = 255,255,255
>P2 = 0,0,255
>
>and so on
>
>thanks

I'd suggest to take a look at the GDI+ classes of VfpX - http://www.codeplex.com/VFPX/Wiki/View.aspx?title=GDIPlusX&referringTitle=Home

Cesar's blog. http://weblogs.foxite.com/vfpimaging

Some articles that deal with gdiPlusX:
http://www.codeplex.com/VFPX/Wiki/View.aspx?title=GDIPlusX%20References&referringTitle=GDIPlusX

If you rather want to write bytes directly, many formats are documented, e.g. at http://www.wotsit.org/
The following test.prg creates a BMP and "paints it black":
#define N_HEADERSIZE	119
#define BLACKPIXEL		chr(0x00)
#define WHITEPIXEL		chr(0xFF)
#define REDPIXEL		chr(0x99)
#define YELLOWPIXEL		chr(0xBB)

lparameters tcColor

*!*	set step on
local lcPixel
do case
	case empty(m.tcColor) OR lower(m.tcColor) == "black"
		lcPixel = BLACKPIXEL
	case lower(m.tcColor) == "white"
		lcPixel = WHITEPIXEL
	case lower(m.tcColor) == "red"
		lcPixel = REDPIXEL
	case lower(m.tcColor) == "yellow"
		lcPixel = YELLOWPIXEL
	otherwise
		return .F.
endcase

local lcFileStream, lcHeader
lcFileStream = filetostr(home()+'fox.bmp')
lcHeader = left(m.lcFileStream,N_HEADERSIZE)

local lcBody, i
lcBody = space(0)
for i = 1 to len(m.lcFileStream) - N_HEADERSIZE
	lcBody = m.lcBody + m.lcPixel
endfor

local lcFile
lcFile = 'test55.bmp'

local lcSafety
lcSafety = set('safety')
set safety off
strtofile(m.lcHeader+m.lcBody,m.lcFile)
set safety &lcSafety

declare integer ShellExecute ;
	in shell32.DLL ;
	integer nWinHandle, ;
	string cOperation, ;
	string cFileName, ;
	string cParameters, ;
	string cDirectory, ;
	integer nShowWindow
ShellExecute( 0, 'open',m.lcFile,'',fullpath(curdir()),0)
hth
-Stefan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform