I am working on a project involving Windows Enhanced Metafiles (.EMF) and am looking for some insight on the "logical coordinates" of text records withinin the file. My goal is to display the EMF file in a .NET control, then allow the user to select a rectangular portion of the image, then retrieve the text contained within the selection. As I understand it, this will involve translating the coordinates of the user's click within the device context displaying the file into the "logical coordinates" of the EMF text records. I'm enumerating the file and pulling the data out of the text records with this code:
if (recordType == EmfPlusRecordType.EmfExtTextOutW)
{
Marshal.Copy(data, dataArray, 0, dataSize);
Int32 nChars = Marshal.ReadInt32(data, 36);
Int32 rclBounds_left = Marshal.ReadInt32(data, 0);
Int32 rclBounds_top = Marshal.ReadInt32(data, 4);
Int32 rclBounds_right = Marshal.ReadInt32(data, 8);
Int32 rclBounds_bottom = Marshal.ReadInt32(data, 12);
Int32 exScale = Marshal.ReadInt32(data, 20);
Int32 eyScale = Marshal.ReadInt32(data, 24);
Int32 ptlReferencex = Marshal.ReadInt32(data, 28);
Int32 ptlReferencey = Marshal.ReadInt32(data, 32);
Int32 rcl_left = Marshal.ReadInt32(data, 48);
Int32 rcl_top = Marshal.ReadInt32(data, 52);
Int32 rcl_right = Marshal.ReadInt32(data, 56);
Int32 rcl_bottom = Marshal.ReadInt32(data, 60);
System.Text.UnicodeEncoding TextUTF16 = new System.Text.UnicodeEncoding();
dataString = TextUTF16.GetString(dataArray, Marshal.ReadInt32(data, 40) - 8, nChars * 2);
}
I am not too familiar with working with these types of files, but I believe I am pulling all of the data I need. However, I'm finding it difficult to find documentation to help me understand all of it thoroughly. Does anyone have any insight on how to convert the "logical coordinates" specified in this data into the coordinates of the device displaying the file? Any assistance would be greatly appreciated.