Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] How to send screenshots from C# server to android client?

Posted on November 11, 2022 By

Solution 1 :

Is the screenshot data from in proper format? Try saving the screenshot to a file and read the raw bytes from the file and send it to the server.

Solution 2 :

I hope I understood your issue correctly, please try this method out.

private static Bitmap getBitmapFromString(String jsonString) {
    byte[] decodedString = Base64.decode(jsonString, Base64.DEFAULT);
    Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
    return decodedByte;
}

Problem :

I created socket connection between Server and Android Client and sent Images as byte Array but I can’t find a way to decode byte Array in android.

Every time I try Image = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); I get errors like

SkAndroidCodec:: NewFromStream returned null

unknown bmp header format

Comments

Comment posted by blackapps

You send an image as byte array. Ok. But what kind of image? A bitmap? Don’t do that. Send a jpg or png.

Comment posted by developer.android.com/reference/android/graphics/BitmapFactory

The byte array should contain compressed image data. So no bitmap.

Comment posted by Dhruv Kansara

I ended up converting it to a string and encoding with base64 and vice versa. It worked like a charm. Thanks for all the answers

Comment posted by blackapps

That will not help if the byte array still contains a bitmap.

READ  [FIXED] android - Play console giving error using MANAGE_EXTERNAL_STORAGE?
Powered by Inline Related Posts
Android Tags:android, bitmap, bitmapfactory, c#, sockets

Post navigation

Previous Post: [FIXED] android – Build not succed in flutter
Next Post: [FIXED] kotlin – Opening the application from the results google.com, always directs to the home page of WebView Android

Related Posts

[FIXED] android – hiding keyboard only makes keyboard semi-transparent/faded Android
[FIXED] user interface – Android : Change checkbox color (boxbackground and tick mark color) Android
[FIXED] How to make the flutter app on android that constantly run in the background until force stop or uninstall it? Android
[FIXED] xml – Does Updating an Android Library cause Error in my Code? Android
[FIXED] crashlytics – Missing class com.google.android.datatransport.runtime.ForcedSender Android
[FIXED] How to remove the blank white screen in my android phone in a react native project? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme