dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
699 stars 1.54k forks source link

Awful docs on imaging.proprertyitems #1643

Open janhec opened 5 years ago

janhec commented 5 years ago

The documentation is absolutely basic beginner style superficial, see example. The real point here is how to get other typed values from a byte array, which is not evident. Next, in the rather important case of georeferencing geotiff through property ID 335500, the type given is wrong: array of integer (7) instead of array of doubles. To finish it off, according to the doc on the propertyitem type, array of doubles is not even a possible type. Please go and fix this really quickly!

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

mairaw commented 5 years ago

Thanks for your feedback @janhec. We do invest in adding more information on APIs that are heavily used and that's not one of them.

But I'd like to understand better your comments about the return value because that's the return type automatically seen by our reflection tool. For which platform is that information wrong since I'm not familiar with georeferencing geotiff through property ID 335500. Can you share some code with us that would illustrate the problem?

janhec commented 5 years ago

Hello Maira, Some code, checks and niceties of all kinds left out: Windows Forms C++ / dlr PictureBox ^ pb; pb->Image = gcnew Bitmap(marshal_as<String^>(fn)); // fn is a tif filename, part of a map, see e.g. this geotiff http://geodata.nationaalgeoregister.nl/top25raster/extract/kaartbladen/TOP25raster_37B.zip?formaat=geotiff from this provider https://mijn.pdok.nl/nl/producten/pdok-downloads/basisregistratie-topografie/topraster/topraster-actueel/top25raster ... if (ext && (!_stricmp(ext, ".tif") || !_stricmp(ext, ".tiff"))) { geovalid = true; auto pixscale = img->GetPropertyItem(33550); // hex 0x830E if (pixscale->Len >= 16) { // copying seems the only possibility for (int i = 0; i < 16; i++) buf[i] = pixscale->Value[i]; double dv = (double)buf; IMscale = { dv[0], -fabs(dv[1]) }; } else geovalid = false; auto tiepoint = img->GetPropertyItem(33922); // // hex 0x8482. tiepoint are coordinates of left upper corner in projection if (tiepoint->Len >= 48) { for (int i = 0; i < 48; i++) buf[i] = tiepoint->Value[i]; double dv = (double)buf; IMAnchor = { dv[3] - dv[0] dv[1], dv[4] - dv[1] dv[5] }; } else geovalid = false; } .... These are the most important for my purpose (georeference pixel coordinates, already knowing the projection). Help has the function and PropertyItem.Id Property (System.Drawing.Imaging), explaining about many property ID's, which is fine. The return value of GetPropertyItem() is a PropertyItem, which gives the following help (methods left out on purpose) PropertyItem Class (System.Drawing.Imaging) PropertyItem Class [image: Visual Studio 2015][image: Visual Studio 2015] Send Feedback DevDocs@Microsoft.com?subject=MSDN%5e*ahafhz84%5e*VS%5e*100%5e*EN-US&body=Visual%20Studio%20feedback%20policy%3a%20http%3a%2f%2fmsdn.microsoft.com%2fEN-US%2flibrary%2fee264131(VS.110).aspx on this topic to Microsoft. [image: Online]View this topic online https://msdn.microsoft.com/EN-US/library/ahafhz84(v=VS.100,d=hv.2).aspx in your default browser.

Encapsulates a metadata property to be included in an image file. Not inheritable. Inheritance Hierarchy <#>

System:: Object System.Drawing.Imaging:: PropertyItem

Namespace: System.Drawing.Imaging Assembly:System.Drawing (in System.Drawing.dll) Syntax <#>

JavaScript C# C++ F# JScript VB View ColorizedCopy to Clipboard

public sealed class PropertyItem

public sealed class PropertyItem

public ref class PropertyItem sealed

public ref class PropertyItem sealed

[]type PropertyItem = class end

[] type PropertyItem = class end

'Declaration Public NotInheritable Class PropertyItem

'Declaration Public NotInheritable Class PropertyItem

The PropertyItem type exposes the following members. Properties <#>

Show: InheritedProtected No members matching the current filter Name Description [image: Public property] Id Gets or sets the ID of the property. [image: Public property] Len Gets or sets the length (in bytes) of the Value property. [image: Public property] Type Gets or sets an integer that defines the type of data contained in the Value property. [image: Public property] Value Gets or sets the value of the property item.

The examples show how to display each member of proptyItem, which i thought was useless. Help on the type member:

PropertyItem.Type Property (System.Drawing.Imaging) The following table shows integers and the types they represent.

Integer

Represented Type

1

Specifies that Value is an array of bytes.

2

Specifies that Value is a null-terminated ASCII string. If you set the type data member to ASCII type, you should set the Len property to the length of the string including the null terminator. For example, the string "Hello" would have a length of 6.

3

Specifies that Value is an array of unsigned short (16-bit) integers.

4

Specifies that Value is an array of unsigned long (32-bit) integers.

5

Specifies that Value data member is an array of pairs of unsigned long integers. Each pair represents a fraction; the first integer is the numerator and the second integer is the denominator.

6

Specifies that Value is an array of bytes that can hold values of any data type.

7

Specifies that Value is an array of signed long (32-bit) integers.

10

Specifies that Value is an array of pairs of signed long integers. Each pair represents a fraction; the first integer is the numerator and the second integer is the denominator. which lacks the array of doubles which is obviously needed in this case. The value returned in the code was 7, which is misleading.

Additional info about the tags is most easily available through gdal xtiffio.h https://www.dropbox.com/s/dphn2074zrlj688/xtiffio.h?dl=0 and tiffio.h https://www.dropbox.com/s/i1m57cj0zrm8cva/tiffio.h?dl=0. In fact I debugged the gdalinfo project to find out what they did because I do not yet want to include the whole library in my code. I have to make this bit of code more resilient, but I'll do that when the need arises.

Hope this clarifies.. My real gripe is the type error and in a lesser way, no help on how to transform these tags in managed code. About myself: I am a professional but not a professional developer, however, I did a lot of C and C++ (leave out one +) to flesh out complex professional models. Now I am working on a quick and dirty GIS, which can already be demonstrated, but has countless loose ends, to be filled in when the model it provides interaction with, needs it. Thank you for your reaction, Jan

On Sun, Jan 20, 2019 at 12:34 AM Maira Wenzel notifications@github.com wrote:

Thanks for your feedback @janhec https://github.com/janhec. We do invest in adding more information on APIs that are heavily used and that's not one of them.

But I'd like to understand better your comments about the return value because that's the return type automatically seen by our reflection tool. For which platform is that information wrong since I'm not familiar with georeferencing geotiff through property ID 335500. Can you share some code with us that would illustrate the problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/dotnet-api-docs/issues/1643#issuecomment-455824115, or mute the thread https://github.com/notifications/unsubscribe-auth/AOYTr5-5JbKa5p9NUxPNbyeRL6yurXeRks5vE6tsgaJpZM4aIkzr .

mairaw commented 5 years ago

@merriemcgaw @Tanya-Solyanik is this a winforms type? If so, can you help out?

janhec commented 5 years ago

Hi Maira, I'm a bit out of it right now, I'll look into it when I restart this project. Thanks for your interest, Jan

On Wed, Aug 7, 2019 at 10:47 PM Maira Wenzel notifications@github.com wrote:

@merriemcgaw https://github.com/merriemcgaw @Tanya-Solyanik https://github.com/Tanya-Solyanik is this a winforms type? If so, can you help out?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/dotnet-api-docs/issues/1643?email_source=notifications&email_token=ADTBHL66FDVJ5FUKS4XRYELQDMYGHA5CNFSM4GRCJTV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3ZVEQQ#issuecomment-519262786, or mute the thread https://github.com/notifications/unsubscribe-auth/ADTBHL3LGDO7C6223PVDJEDQDMYGHANCNFSM4GRCJTVQ .