Android Question Picture from camera with stripes

DonManfred

Expert
Licensed User
Longtime User
Hallo,

i´m using the Lib Camera (version: 2.20) with the code

B4X:
Dim w=1280,h=960 As Int
camEx.SetPictureSize(w, h)
ToastMessageShow("Bildgröße: " & 1280 & "x" & 960& " Pixel", False)
camEx.SetJpegQuality(100)
camEx.SetFocusMode("auto")
camEx.CommitParameters
camEx.StartPreview


and

B4X:
Sub Camera1_PictureTaken (Data() As Byte)
    camEx.StopPreview
  Dim b64 As Base64
    Dim hex As ByteConverter
    Dim dest As String
    dest = randomname(8)&".jpg"
    Do While File.Exists(File.DirRootExternal, dest) = True
        dest = randomname(8)&".jpg"
    Loop
    dummybild = hex.HexFromBytes(Data)
    Dim dir As String = File.DirRootExternal
    camEx.SavePictureToFile(Data, dir, dest)

On my Smartphone (Samsung Galaxy Note) everything works good. But with the Phone of my Boss (Samsung Galaxy S4) it didn´t...

On the S4 i got a damaged file written to the SD-Card. The file is 2,72mb for an jpg of 960x1280 Pixels!?

See sample. THIS Picture in Attachment is resized from 960x1280 to 960x1280 (grins) with irfanview. THIS jpg is only 98kb in size.

What can i do to fix this problem? Too much filesize with the jpg and it is not what i have a picture made of.

Any help or suggestions are welcome ;)

Thanx in advance


PS: I´m using CameraEx-Class 1.20 if this is important...
 

Attachments

  • DHKGKWJE.jpg
    DHKGKWJE.jpg
    97.7 KB · Views: 247
Last edited:

DonManfred

Expert
Licensed User
Longtime User
What is the purpose of this line:
B4X:
dummybild = hex.HexFromBytes(Data)

This can break your app as it will create a huge string.

I know. For this i want to limit the Picturesizes to get as low data as i need... Getting the smallest picture i need.
If i make a picture with size of 960x1280 the jpg is approx 100kb in size on my phone... HexFromBytes makes 200kb out of this.

But the "wrong" Picture above is 2,7mb in Original (5,4mb HEXed)

PS: The purpose of this is to get data which i can use to transfer the image to our server...
First i tried to use mime-encode in b4a, transfer the data to our server where a php-script should decode the mime-data. PHP mime_decode is not compatible with b4a-mime-encode. So i needed a other solution which can recoded to the original on our server (showing the image in our Windows-Software)... I used HEX then. I know the size of the image would be doubled BUT is is compatible with PHP hex-Decode and i can use the image on windows also..
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Found the right syntax:

B4X:
Dim PictureSizes As List = camEx.GetSupportedPicturesSizes
Log("CamSizes: "&PictureSizes)

Gives me an Output of
B4X:
CamSizes: (ArrayList) [[Height=2448, IsInitialized=false, Width=3264
], [Height=1968, IsInitialized=false, Width=3264
], [Height=1536, IsInitialized=false, Width=2048
], [Height=1232, IsInitialized=false, Width=2048
], [Height=960, IsInitialized=false, Width=1280
], [Height=480, IsInitialized=false, Width=800
], [Height=480, IsInitialized=false, Width=640
]]

On my Galaxy Note... This is OK. I tried to set the picturesize to 960x1280 and it works on my Note...

On the S4 i get a nearly complete other list of sizes... The only size which is available on S4 AND note is 640x480 pixel.
If i set the Picturesize to 640x480 then the images saved is not corrupted.

Thanx for your answer Erel! This helps me to find the right way for a solution. Now i have to write a routine which find out the possible sizes of different phones to get more information from other phones...
 
Upvote 0
Top