Picture.ToData Issue


I am trying to compare 2 images by storing a hash of one and then comparing against the produced hash of another (SHA1). I’m having problems with getting image data. Whatever I try (and I seem to be going by the docs), I get an error message:

I realise others have had issues with Enum’s before but this says that the Formats member doesn’t exist. Am I missing something ?

Thanks in advance,

EDIT: Version 2019R3.1 Win10

You’ll need to use the classic API for this project. API 2.0 is not available in older IDEs or the Web framework, but that’s all that’s available with the online documentation.

Edit: You updated which IDE version you’re using, so I think this is a result of using the Web framework

Thanks Tim but this is a desktop project.

Do you have something in your project that conflicts with the naming? Why are you trying to cast the enumerations when passing them? What happens if you base the line off the docs line .ToData(Picture.Formats.JPEG, Picture.QualityHigh) ?

Answered the second two questions by staring at your screenshot.

The first syntax-error thing is because you don’t use enumerations anything close to like that. The “no member named formats” line is how the function is supposed to work. If it’s a desktop project, I’d suspect a naming conflict next.

The quality parameter is supposed to be optional, and since it looks like your working with PNG try removing the parameter just to see if this might be an API 2.0 glitch.

Thanks Tim - I was trying all angles.

Just to be sure, I tried the docs (only diff was the quality param) and below is the result:


mb = c.Picture.ToData(Picture.Formats.JPEG) 

And then get 4 errors with it:

Formats not a member of Picture
Int32 has no member named JPEG
Parameter “format” expects enum Picture.Formats, but this is type Int32
Type mismatch error. Expected class MemoryBlock, but got Int32

EDIT: Trying in 2019R1.1

I would look for a naming conflict because it seems like something in your project (or plugins?) is defining “Picture”
I fired up 2019 R3.1 because I’m quite curious, and had no issues :confused:

As a test, this should compile:

dim tp as new Picture(32, 32) dim tmb as MemoryBlock = tp.ToData(Picture.Formats.PNG)

Ok thanks Tim - I’ll have a look. In this instance all I did was open an example project (Desktop -> Container Controls -> Download) and make some minor mods to it.

Found it. I am writing a clipboard utility and had set the Super for the class to ‘Clipboard’. Removing that did the trick.