프로젝트

일반

사용자정보

개정판 92442e4a

ID92442e4a9bf39e4238533981c0425b15f25b406a
상위 96c13fad
하위 48f69651

김태성이(가) 5년 이상 전에 추가함

image load 수정

Change-Id: I35e6802b9bde1cd6a7c9787f3a71fb53d6ea10ad

차이점 보기:

KCOM/Views/MainMenu.xaml.cs
554 554
            var pageUri = pageNavigator.CurrentPage.PageUri;
555 555
            var contentScale = zoomAndPanControl.ContentScale;
556 556

  
557
            #region 이미지 로딩 수정
557
            #region 페이지 이미지 로딩 수정
558 558

  
559
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
559
            // ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
560
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth, pageHeight);
561
            ScaleImage(pageWidth,pageHeight);
560 562

  
561 563
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
562 564
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
......
672 674
            this.pageNavigator.ChangePage(e.PageNumber);
673 675
        }
674 676

  
675
        public async System.Threading.Tasks.Task<BitmapImage> GetDownloadImageAsync2(Uri uri,double pageWidth,double pageHeight)
676
        {
677
            BitmapImage defaultBitmapImage = new BitmapImage();
678

  
679
            using (System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient())
680
            {
681
                using (var responseStream = await httpClient.GetStreamAsync(uri))
682
                {
683
                    using (var memoryStream = new System.IO.MemoryStream())
684
                    {
685
                        await responseStream.CopyToAsync(memoryStream);
686

  
687
                        defaultBitmapImage.BeginInit();
688
                        defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
689
                        defaultBitmapImage.StreamSource = memoryStream;
690
                        defaultBitmapImage.DecodePixelWidth = (int)(pageWidth * (zoomAndPanControl.ContentScale * 10));
691
                        defaultBitmapImage.DecodePixelHeight = (int)(pageHeight * (zoomAndPanControl.ContentScale * 10));
692
                        defaultBitmapImage.EndInit();
693
                        defaultBitmapImage.Freeze();
694
                    }
695
                }
696
            }
697
            //defaultBitmapImage.Dispatcher.Invoke(() => { 
698
            //    defaultBitmapImage.BeginInit();
699
            //    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
700
            //    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
701
            //    defaultBitmapImage.UriSource = uri;
702
            //    defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth);
703
            //    defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight);// * zoomAndPanControl.ContentScale
704
            //    defaultBitmapImage.EndInit();
705

  
706
            //    ViewerDataModel.Instance.ImageViewPath = null;
707
            //    Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
708
            //    if (defaultBitmapImage.IsDownloading)
709
            //    {
710
            //        Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
711
            //        defaultBitmapImage.DownloadCompleted += (ex, arg) =>
712
            //        {
713
            //            defaultBitmapImage.Freeze();
714
            //            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
715
            //            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
716
            //            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
717

  
718
            //            //image dispose
719
            //            defaultBitmapImage = null;
720

  
721
            //            GC.Collect();
722
            //        };
723
            //    }
724
            //});
725

  
726
            System.Diagnostics.Debug.WriteLine("이미지 다운로드");
727
            return defaultBitmapImage;
728
        }
729

  
730 677
        /// <summary>
731 678
        /// called after page is changed
732 679
        /// </summary>
......
5293 5240
            e.Effects = DragDropEffects.None;
5294 5241
        }
5295 5242

  
5296
        private async void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5243
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5297 5244
        {
5298 5245
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5299 5246
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5300
            var pageUri = pageNavigator.CurrentPage.PageUri;
5301
            var contentScale = zoomAndPanControl.ContentScale;
5302 5247

  
5303
            ViewerDataModel.Instance.ImageViewPath = await ImageSourceHelper.GetDownloadImageAsync(pageUri, pageWidth * contentScale, pageHeight * contentScale);
5248
            ScaleImage(pageWidth, pageHeight);
5249
        }
5250

  
5251
        /// <summary>
5252
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5253
        /// </summary>
5254
        /// <param name="pageWidth">원본 사이즈</param>
5255
        /// <param name="pageHeight">원본 사이즈</param>
5256
        /// <returns></returns>
5257
        private void ScaleImage(double pageWidth,double pageHeight)
5258
        {
5259
            mainPanel.Scale = (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5304 5260
        }
5305 5261

  
5306 5262
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)