0
여러 장의 사진을 인쇄하기 위해 Microsoft의 인쇄 예제를 수정했지만 이미지가 항상 세로로 맞춰져 있는데 어떻게 가로로 정렬 할 수 있습니까? Microsoft에 따르면 사진은 자동으로 회전해야합니다. 인쇄 예는 https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Printing입니다.UWP 여러 이미지 인쇄
''' <summary>
''' Generates a page containing a photo.
''' The image will be rotated if detected that there is a gain from that regarding size (try to maximize photo size).
''' </summary>
''' <param name="photoNumber">The photo number.</param>
''' <param name="pageDescription">The description of the printer page.</param>
''' <returns>A task that will return the page.</returns>
Private Async Function GeneratePageAsync(photoNumber As Integer, pageDescription As PageDescription) As Task(Of UIElement)
Dim page As New Canvas() With {
.Width = pageDescription.PageSize.Width,
.Height = pageDescription.PageSize.Height
}
Dim viewablePage As New Canvas() With {
.Width = pageDescription.ViewablePageSize.Width,
.Height = pageDescription.ViewablePageSize.Height
}
viewablePage.SetValue(Canvas.LeftProperty, pageDescription.Margin.Width)
viewablePage.SetValue(Canvas.TopProperty, pageDescription.Margin.Height)
' The image "frame" which also acts as a viewport
Dim blnLandScape As Boolean
If MainPage._picsperprint = 2 OrElse MainPage._picsperprint = 6 OrElse MainPage._picsperprint = 8 OrElse MainPage._picsperprint = 32 OrElse MainPage._picsperprint = 128 Then
blnLandScape = True
ElseIf MainPage._picsperprint > 0 Then
blnLandScape = False
'PrintPageSqareNumbers(e, PrintPage)
ElseIf MainPage._picsperprint = -1 Then
'PrintPageSized(e, PrintPage)
End If
' Return an async task that will complete when the image is fully loaded.
Dim blnSuccess As Boolean = False
Dim pos As Integer = (photoNumber - 1) * MainPage._picsperprint
For i As Integer = 0 To _Rows - 1
For ii = 0 To _Columns - 1
If pos + i * (_Columns) + ii >= MainPage.checkedItems.Count Then Exit For
Dim height As Integer = pageDescription.PictureViewSize.Height
Dim width As Integer = pageDescription.PictureViewSize.Width
height = height/_Rows
width = width/_Columns
Dim photoView As New Grid() With {
.Width = width,
.Height = height
}
' Center the frame.
Dim Left As Integer = (viewablePage.Width - photoView.Width * _Columns)/2
Dim Top As Integer = (viewablePage.Height - photoView.Height * _Rows)/2
Top += height * i
Left += width * ii
photoView.SetValue(Canvas.LeftProperty, Left)
photoView.SetValue(Canvas.TopProperty, Top)
Dim position As Integer = (pos + i * (_Columns) + ii)
Dim Item As ImgListItem = GetItemOfPosition(position)
Dim bitmap As WriteableBitmap = Await Item.LoadBitmapAsync(False)
If bitmap IsNot Nothing Then
Dim image As New Image() With {
.Source = bitmap,
.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left,
.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top
}
' Use the real image size when croping or if the image is smaller then the target area (prevent a scale-up).
If photoScale = Scaling.Crop OrElse (bitmap.PixelWidth <= width AndAlso bitmap.PixelHeight <= height) Then
image.Stretch = Stretch.None
image.Width = bitmap.PixelWidth
image.Height = bitmap.PixelHeight
End If
' Add the newly created image to the visual root.
blnSuccess = True
photoView.Children.Add(image)
viewablePage.Children.Add(photoView)
End If
Next ii
Next i
If blnSuccess Then
page.Children.Add(viewablePage)
' Return the page with the image centered.
Return page
Else
Return Nothing
End If
End Function
사용중인 인쇄 예제는 무엇입니까? 그리고 그림이 자동으로 회전해야한다는 것을 어디에서 보았습니까? – Scavenger
코드는 https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Printing에서 제공되며 주석에 '' '이미지가 표시됩니다. 크기에 관한 것 (사진 크기를 최대화하려고 시도하십시오). –