Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

According to the MSDN Refence Library I should be able to use GetPixel when attempting to return the color of a particular pixel in a specifiec bitmap.

 

Unfortunately I get an error saying a ";" is expected when I run the following line ...

 

var imageObj = new Bitmap(strMaster));

 

Can anyone help me with what I am doing wrong other than using JScript for something I should be using C# to accomplish? Trust me, I'd prefer to use C# but the automated test harness we're using only accepts JScript.

Posted

Thanks, I removed the extra parentheses and wound up with an error stating I Bitmap was undefined. It looks like JScript is treating Bitmap as an undefined function. I'm thinking I might need to create a new ActiveXObject accessing a bitmap through an application like MSPaint using the code such as

 

var imageObj = new ActiveXObject("MSPaint.Application");

 

but then again I could also create a new object class inheriting from Image and including the structure of a Bitmap but that seems to be a little like reinventing the wheel. Also, I'm unsure as to whether .Application will work with MSPaint since it's not usually considered an Office application.

 

Does anyone have any fresh ideas as to how I can extract the color of a pixel from a bitmap using JSCript 'cause I'm starting to get frustrated.

 

Thanks.

Posted

I removed the extra parentheses and wound up with an error stating I Bitmap was undefined

 

System.Drawing.Bitmap();

Gamer extraordinaire. Programmer wannabe.
Posted
System.Drawing.Bitmap will work in JScript? I should probably mention I'm accessing this through the Windows scripting host and not an ActiveX instance like IE6.x or solmething else.
Posted
I honestly don't know anything about JScript, but I'm assuming that you're using the .NET framework and GDI+ (since that's the area you posted in). In which case, System.Drawing is where the Bitmap class is located.
Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

I don't think WSH supports .NET unless they've improved it. The JScript is just what you'd get in the browser, but with more rights (to create objects and such without any security popups).

 

I can't remember offhand the names of the objects you want - haven't used COM in over a year now :) - but it's something like:

var imageObj = new ActiveXObject("stdole.StdPicture");
imageObj = LoadPicture("filename")

 

I'm about 80% sure the StdPicture is what you want. LoadPicture might be a VBScript specific function, if it even exists there. I know it works in VB6 :)

 

Anyway, I'm still not sure how you'd get a pixel from the StdPicture object.

 

What are you trying to do with WSH that you need to get a pixel? Is this trying to look at another window and get the pixels? If so, you're likely to need the API which I don't think is available in WSH. You might be better off coding this whole thing in either VB6 or at least making a VB6 DLL that you can then use from WSH.

 

I'd suggest .NET, but I believe you'd have to code your .NET DLL to be a COM DLL which is probably more work than you want :)

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...