Italian Ridimensionare foto dopo averla catturata

Yeshua

Member
Licensed User
Longtime User
Salve ragazzi,
qualcuno potrebbe darmi una mano?
Vorrei sapere come è possibile ridimensionare una foto dopo averla catturata
e salvata nella mmc.

questo è il mio codice:

Sub CameraY_PictureTaken2(Data() As Byte)
CameraY.StartPreview
CameraY.FlashOff
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "Image" & CounterY & ".bmp", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "Image" & CounterY & ".bmp"), True)
End Sub

:sign0085:
 

Yeshua

Member
Licensed User
Longtime User
Grazie genesi.

ho provato ma nn è quello che cercavo.
nn riesco a ridimensionare la foto dopo averla catturata.
 

genesi

Active Member
Licensed User
Longtime User
Non sò se hai risolto penso di no altrimenti avresti postato il risultato
Allora la tecnica è questa
B4X:
Sub ResizeBitmap(original As Bitmap, width As Int, height As Int) As Bitmap
    Dim new As Bitmap
    new.InitializeMutable(width, height)
    Dim c As Canvas
    c.Initialize2(new)
    Dim destRect As Rect
    destRect.Initialize(0, 0, width, height)
    c.DrawBitmap(original, Null, destRect)
    Return new
End Sub

Dacci notizie
 

Yeshua

Member
Licensed User
Longtime User
:sign0148:
non so se si nota che sono ancora agli inizi ma nn riesco proprio a risolvere.
l'immagine continua a mantenere le sue dimensioni anche dopo la cattura.

sto utilizzando le seguenti librerie: ACL (version 4.60), Phone (version 1.75) e naturalmente Core (version 1.90)

questo è il mio progetto:

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim VerticalScreen As Phone
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim PanelCamera As Panel
   Dim CounterY As Int
   Dim CameraY As AdvancedCamera
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("photo")
   VerticalScreen.SetScreenOrientation(1)
End Sub

Sub CameraY_Ready(Succes As Boolean)
   If Succes Then
      CameraY.OriPortrait
      CameraY.StartPreview
   End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   CameraY.StopPreview
   CameraY.Release
End Sub

Sub Activity_Resume
   CameraY.Initialize(PanelCamera,"CameraY")
End Sub

Sub CameraY_PictureTaken2(Data() As Byte)
   CameraY.StartPreview
   Dim out As OutputStream
   out = File.OpenOutput(File.DirRootExternal, "Image" & CounterY & ".bmp", False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
   ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "Image" & CounterY & ".bmp"), True)
End Sub

Sub exit_Click
   ExitApplication
End Sub

Sub take_Click
   CameraY.TakePicture2(90)
   CounterY = CounterY + 1
End Sub
 
Top