Նավարկեք .NET-ում գերմեծ պատկերներ դիտելիս

Բլոգի կատեգորիա՝ Պատկերացում.NET

13.05.2020

Այս հոդվածը նկարագրում է, թե ինչպես օգտագործել VintaSoft Imaging .NET SDK-ից ImageMapTool դասը մեծ և գերմեծ պատկերներ դիտելու համար:

Եկեք որպես օրինակ օգտագործենք JPEG2000 պատկեր՝ 4067 մեգապիքսել (35878x113378 պիքսել) չափսերով:
Ահա JPEG2000 պատկերի էկրանի նկարը՝ 1% մեծացմամբ VintaSoft Imaging Demo:
Very large JPEG2000 image with 1% zoom in VintaSoft Imaging Demo

Ահա JPEG2000 պատկերի էկրանի նկարը՝ 10% մեծացմամբ VintaSoft Imaging Demo:
Very large JPEG2000 image with 10% zoom in VintaSoft Imaging Demo

Շատ մեծ պատկեր դիտելիս հաճախ դժվար է հասկանալ, թե պատկերի որ մասում եք գտնվում այս պահին և որտեղ պետք է շարժվել՝ ցանկալի տեղ հասնելու համար: Ընդհանուր առմամբ, այս անհարմարությունը կարելի է լուծել՝ պատկերը փոքրացնելով, ապա ցանկալի տարածքը մեծացնելով: Սակայն այն դեպքում, երբ պատկերի վերծանումը բավականին ռեսուրսատար է, այն կարող է անընդունելիորեն շատ ժամանակ պահանջել: Պատկերի քարտեզի օգտագործումը ImageMapTool դասի միջոցով խնդիրը լուծելու հարմարավետ և էլեգանտ միջոց է:

VintaSoft Imaging Demo-ում պատկերի քարտեզը կարող է միացվել "Դիտում -> Պատկերի քարտեզի կարգավորումներ..." ընտրացանկի տարրի միջոցով: Ստորև բերված էկրանի նկարը ցույց է տալիս պատկերի քարտեզի կարգավորումները VintaSoft Imaging Demo-ում.
Default image map settings in VintaSoft Imaging Demo


Իրականում պատկերի քարտեզը փոքր պատկերի դիտիչ է, որը գտնվում է հիմնական պատկերի դիտիչի վերևում և ցույց է տալիս նույն պատկերը, բայց այլ մասշտաբավորման ռեժիմով։ Ստորև բերված էկրանի նկարը ցույց է տալիս պատկերի քարտեզի կարգավորումները՝ 1/25 մասշտաբի գործակցով՝ հիմնական պատկերի դիտման ներկայիս մեծացման գործակցի նկատմամբ։
Image map settings with custom scale factor in VintaSoft Imaging Demo


ImageMapTool դաս.

ImageViewer.ViewerBufferSize հատկությունը թույլ է տալիս նշել պատկերների դիտման մեջ տեսանելի տարածքի շուրջ ամբողջությամբ քեշավորված տարածքի ուղղանկյան չափը մեգապիքսելներով (դեղին ուղղանկյուն): Ստորև բերված էկրանի նկարը ցույց է տալիս պատկերների դիտման կարգավորումները՝ տեսանելի տարածքի շուրջ քեշավորված տարածքի 6 մեգապիքսել չափսերով.
Image viewer settings with custom size of cached area around visible area in image viewer



Բացի դրանից,Շատ-շատ մեծ պատկերների համար հնարավոր է միաժամանակ օգտագործել պատկերի դիտման ծրագրի մի քանի ImageMapTool տարրեր, որոնցից յուրաքանչյուրն ունի տարբեր հարաբերական մասշտաբավորում։ Սա հնարավոր է CompositeVisualTool դասի շնորհիվ, որը թույլ է տալիս համատեղել մի քանի տեսողական գործիքների ֆունկցիոնալությունը։
Ահա C# կոդը, որը ցույց է տալիս, թե ինչպես ստեղծել 2 պատկերի քարտեզ պատկերի դիտման մեջ։
// create the first image map tool
Vintasoft.Imaging.UI.VisualTools.ImageMapTool imageMap1 = new Vintasoft.Imaging.UI.VisualTools.ImageMapTool();
// specify that image map must be enabled
imageMap1.Enabled = true;
// specify that image map tool must show image in best fit mode
imageMap1.Zoom = 0;
// specify that image map must have size 200x200 pixels
imageMap1.Size = new System.Drawing.Size(200, 200);
// specify that image map must be shown at the left-top corner of image viewer
imageMap1.Anchor = Vintasoft.Imaging.UI.AnchorType.Left | Vintasoft.Imaging.UI.AnchorType.Top;
// specify that image map tool border must have red color
imageMap1.CanvasPen = new System.Drawing.Pen(System.Drawing.Color.Red);
// specify that the border of image's visible region in image map must have lime color
imageMap1.VisibleRectPen = new System.Drawing.Pen(System.Drawing.Color.Lime);

// create the second image map tool
Vintasoft.Imaging.UI.VisualTools.ImageMapTool imageMap2 = new Vintasoft.Imaging.UI.VisualTools.ImageMapTool();
// specify that image map must be enabled
imageMap2.Enabled = true;
// specify that image map tool must show image in 1/25 scale from image viewer zoom
imageMap2.Zoom = 1 / 25f;
// specify that image map must have size 200x200 pixels
imageMap1.Size = new System.Drawing.Size(200, 200);
// specify that image map must be shown at the left-bottom corner of image viewer
imageMap2.Anchor = Vintasoft.Imaging.UI.AnchorType.Left | Vintasoft.Imaging.UI.AnchorType.Bottom;
// specify that image map tool border must have red color
imageMap2.CanvasPen = new System.Drawing.Pen(System.Drawing.Color.Red);
// specify that the border of image's visible region in image map must have lime color
imageMap2.VisibleRectPen = new System.Drawing.Pen(System.Drawing.Color.Lime);

// create composite visual tool that combines first and second image map tools
Vintasoft.Imaging.UI.VisualTools.CompositeVisualTool compositeVisualTool = new Vintasoft.Imaging.UI.VisualTools.CompositeVisualTool(imageMap1, imageMap2);

// set composite visual tool as current visual tool of image viewer
imageViewer1.VisualTool = compositeVisualTool;

Ստորև բերված էկրանի նկարը ցույց է տալիս պատկերի դիտման համակարգը՝ 2 պատկերի քարտեզներով։
Image viewer with 2 image maps in VintaSoft Imaging Demo