B4J Library [B4X] [XUI] xResizeAndCrop

klaus

Expert
Licensed User
To get the cropped image i need a cropped panel, but why?
You don't need a Panel nor Pane!
The CroppedImage method returns a B4XBitmap.
Don't confuse with CroppedView!
This a B4XView where you can automatically copy the cropped image.
 

Alexander Stolte

Expert
Licensed User
ou don't need a Panel nor Pane!
but on the code i see this:
ExtractCroppedImage:
Private Sub ExtractCroppedImage
    Private rectDest As B4XRect
    Private cLeft, cTop, cWidth, cHeight As Int
   
    If xpnlCropped.IsInitialized Then
        If rectImage.Width / rectImage.Height > imvCroppedWidth / imvCroppedHeight Then
            xpnlCropped.Width = imvCroppedWidth
            xpnlCropped.Height = imvCroppedWidth / rectImage.Width * rectImage.Height
        Else
            xpnlCropped.Height = imvCroppedHeight
            xpnlCropped.Width = imvCroppedHeight / rectImage.Height * rectImage.Width
        End If
        xcvsCropped.Resize(xpnlCropped.Width, xpnlCropped.Height)
       
        cLeft = Floor((rectImage.Left - ximvImage.Left) * PixelScale)
        cTop = Floor((rectImage.Top - ximvImage.Top) * PixelScale)
        cWidth = Ceil(rectImage.Width * PixelScale)
        cHeight = Ceil(rectImage.Height * PixelScale)
        xbmpCropped = xbmpImage.Crop(cLeft, cTop, cWidth, cHeight)
       
        rectDest.Initialize(0, 0, xpnlCropped.Width, xpnlCropped.Height)
       
        xcvsCropped.ClearRect(rectCroppedView)
        xcvsCropped.DrawBitmap(xbmpCropped, rectDest)
        xcvsCropped.Invalidate
    End If
End Sub
and this panel is set on the setCroppedView

if i call CroppedImage without to set a "CroppedView" then the "CoppedImage" is null.
or am I looking at this wrong?
 

klaus

Expert
Licensed User
You are right, there was a problem.
The xResizeAnd Crop Class has been updated to version 1.4 in the first post.
 
Last edited:
Top