Convert byte [] to bitmap
How convert byte [] bitmap and convert bitmap to byte [] image and when to get the image of the server back to a string how to parse this string for byte [] exmple in android it parse like that
byte[] logoImg = Base64.decode(jLogo.getString(i), 0);
Thanks in advance
Hello
You can use the method createBitmapFromBytes of the Bitmap class to convert an array of bytes to a Bitmap image. If you know that the image will be in PNG format you can even use createBitmapFromPNG
Specification of the API:
Tags: BlackBerry Developers
Similar Questions
-
How to convert the object Bitmap to byteArray.
Hi all
I had a problem in the conversion of the bitmap object to. BMP file.
(Real need: capture the screen shot and convert that turned to the screen.) BMP image and I have to keep this image in the SCARD
I shouldn't use any PNGEncodedImage or JPEGEncodedImage )
I capture the screen shot using the
Bitmap BM = new Bitmap (width, height);
Display.screenshot (WB);
to get the data from [] bytes of this bitmap object that I use
Byte [] _bytes = getBytesFromBitmap (bitmap);
public byte [] getBytesFromBitmap (Bitmap bmp) {}
try {}
int height = bmp.getHeight ();
int width = bmp.getWidth ();
int [] rgbdata = new int [width * height];
ByteArrayOutputStream Bos = new ByteArrayOutputStream();
DataOutputStream back = new DataOutputStream (bos);
Graphics g = new Graphics (bmp);
bmp.getARGB(rgbdata,0,width,0,0,width,height);
for (int i = 0; i)< rgbdata.length="" ;="" i++)="">
If (rgbdata [i]! = - 1) {}
dos.writeInt (i);
back. Flush();
//l++;
}
}
Bos.Flush ();
Return bos.toByteArray ();
}
catch (Exception ex) {}
Dialog.Alert ("getBytesFromBitmap:" + ex.toString ());
Returns a null value.
}If I use this byte array in the Sub statement I get the "IllegalArgumentException".
BMPEncodedImage.createEncodedImage (_bytes, 0, _bytes .length);
all can help me how I can get the byte [] data from the bitmap object?
import java.io.ByteArrayOutputStream;import java.io.DataOutputStream;import java.io.IOException; import javax.microedition.lcdui.Image; /** * @author Samuel Halliday */public final class BMPGenerator { /** * @param image * @return * @throws IOException * @see {@link #encodeBMP(int[], int, int)} */ public static byte[] encodeBMP(Image image) throws IOException { int width = image.getWidth(); int height = image.getHeight(); int[] rgb = new int[height * width]; image.getRGB(rgb, 0, width, 0, 0, width, height); return encodeBMP(rgb, width, height); } /** * A self-contained BMP generator, which takes a byte array (without any unusual * offsets) extracted from an {@link Image}. The target platform is J2ME. You may * wish to use the convenience method {@link #encodeBMP(Image)} instead of this. *
http://javablog.co.uk/2007/12/26/j2me-bitmap-encoder/* A BMP file consists of 4 parts:- *
- *
- header *
- information header *
- optional palette *
- image data *
-
CS6 - trying to convert an RGB bitmap image
CS6 - trying to convert an RGB bitmap image (the image is actually a tif). I click on: Image > Mode and bitmap is enabled; everything is grayed out except grayscale. How can I fix it? Thank you!
Convert to grayscale first, followed by RGB.
-
How to convert byte [] EncodedImage rgb565 or bitmap data
Hi all I am playing a video and I want to get snapshot of video as
Byte [] byteArr = videoControl.getSnapshot ("encoding = rgb565");
I try to get the Bitmap as
image = EncodedImage.createEncodedImage (byteArr, 0, byteArr.length);
image bitmap = image.getBitmap ();
but she throws an Exception as IllegalArgumentException.
I get a table of double length than screenWidth * ScreenHeight, perhaps because of the rgb565
How can I convert a byte [] bitmap.
I solve the problem to get the bitmap by building as
image bitmap = new Bitmap (Bitmap.ROWWISE_16BIT_COLOR, Graphics.getScreenWidth (), Graphics.getScreenHeight (), byteArr);
-
I use this method to convert strings in Base64 to Bitmap.
It works fine, except that it takes too long to convert the images.The time increases depending on the size in bytes of the image, as expected.
But I've used a few apps before BB on my 8300 appliance.
and the Base64 images are converted more rapidly than in my application.Is there a faster way to achieve what I need or a way to improve
This code?public convertBase64ToBitmap (String, Byte) {Bitmap image
ByteArrayInputStream bis = new ByteArrayInputStream (pImage.getBytes (), 0, pImage.getBytes () .length);
B64 Base64InputStream = new Base64InputStream (bis);
ByteArrayOutputStream Bos = new ByteArrayOutputStream();
buff Byte [] = new byte [1024];
{for (int len = b64.read (buff); len! = - 1; len = {b64.read (buff))}
Bos.Write (buff, 0, len);
}
Byte [] decoded = bos.toByteArray ();
String dd = new String (decoded);
Byte [] dataArray = dd.getBytes ();
EncodedImage encodedImage = EncodedImage.createEncodedImage (dataArray, 0, dataArray.length);
Bitmap bmp = encodedImage.getBitmap ();
return bmp;
}Thanks in advance!
I just thought of this. I would like to use a direct conversion, but if you want to stick with Base64InputStream
So what follows is probably more effective.
Byte [] inputBytes by performing a = pImage.getBytes () / / only for this operation once...
ByteArrayInputStream bis = new ByteArrayInputStream (inputBytes by doing one, 0, inputBytes.length);
B64 Base64InputStream = new Base64InputStream (bis);
Byte [] dataArray = IOUtilities.streamToBytes (b64);
EncodedImage encodedImage = EncodedImage.createEncodedImage (dataArray, 0, dataArray.length);
Bitmap bmp = encodedImage.getBitmap ();
return bmp;Don't forget that you can use the Profiler to check performance.
-
I'm trying to convert an array of bytes into a bitmap image. The byte array returned from a url, if you enter the url in Internet Explorer, it is automatically returned. What would be the best way to get the data returned by the url, and how would it be better to convert as bitmap?
There is an example here:
-
Hello
on the 11g R2,.
If a Column1 is VARCHAR2 (20 byte) and column2 is VARCHAR2(20 char), which needs more disk space to be stored (let's assume we have just one line)?
We are in non-unicode mode.
If I MYTABLE (column1 VARCHAR2 (20 byte)) how can I convert to MYTABLE (column1 VARCHAR2 (20 CHAR))?
Thank you.user522961 wrote:
Thank you all.
I wanted to understand the reason for the parameter NLS_LENGTH_SEMANTICS to CHARAs already explained more high semantic length is designed to define the size of a column in the table so that you do not get the error of allocation of space in the column of table such as:
oerr ora 12899 12899, 00000, "value too large for column %s (actual: %s, maximum: %s)" // *Cause: An attempt was made to insert or update a column with a value // which is too wide for the width of the destination column. // The name of the column is given, along with the actual width // of the value, and the maximum allowed width of the column. // Note that widths are reported in characters if character length // semantics are in effect for the column, otherwise widths are // reported in bytes. // *Action: Examine the SQL statement for correctness. Check source // and destination column data types. // Either make the destination column wider, or use a subset // of the source column (i.e. use substring).
If your application requires it, you do it because it is so dependent on the application.
Here's a long discussion on the pros and cons of the parameter NLS_LENGTH_SEMANTICS to CHAR: Re: language support of several
-
How to convert a simple bitmap into a vector image?
I need to convert a vector of this shopping cart bitmap image: http://ImageShack.us/a/img94/7391/Cartt.PNG
It's a very simple picture, but when I try to use the tracking of Image tool in CS6 it fails miserably.
Is there a simple way to convert this to a vector image in Illustrator?
Thank you!
A little icon there, Noob.
Big enough to see the details and draw with the pen tool. Or, perhaps a Google search free shopping cart vector icons would be sufficient.
http://lmgtfy.com/?q=vector+shopping+cart+icon
Mike
-
Help me convert (BYTE) V2 to V2 (Char)
Hello!
Please, help me! I have already created several tables that have fields with Varchar2 parameter. Because
Basically, there is Varchar2 (BYTE) parameters, fields created as Varchar2 (BYTE). I have the UTF-8 encoding used in
database. Whereas now, I started to think that 1 tank in UTF not = 1 byte. So, how can I convert all fields
with Varchar2 (Byte) to Varchar2 (TANK)? It is very important to me, now I know that. There are many tables,
in order to edit a lot of time having conducted manually, but create new I can not, because many of the tables is now used :(
Thank you!As I said in my first post, you need a LOG table and an exception block, then an outer join to exclude those who have already succeeded
something like that;
create table log_tbl ( table_name varchar2(30) , column_name varchar2(30) , msg varchar2(200) , error_flag varchar2(1) default 'P') -- P for Pass and F for Fail. / SQL> select table_name, column_name, char_used 2 from user_tab_columns 3 where table_name in ('T1','T2') 4 / TABLE_NAME COLUMN_NAME C ------------------------------ ------------------------------ - T1 A B T2 A B SQL> declare 2 l_Err varchar2(200); 3 begin 4 for r in (select atc.table_name, atc.column_name, atc.data_length 5 from user_tab_columns atc -- You would probably use ALL_ 6 left outer join Log_Tbl lt on (atc.Table_name = lt.Table_Name 7 and atc.Column_name = lt.Column_Name 8 and lt.Error_Flag = 'P') 9 where atc.data_type = 'VARCHAR2' 10 and atc.char_used = 'B' 11 and atc.Table_Name in ('T1', 'T2', 'T3')) loop 12 13 begin 14 execute immediate 'alter table ' || r.table_name 15 || ' modify ' 16 || r.column_name 17 || ' varchar2(' 18 || r.data_length 19 || ' char)'; 20 21 insert into Log_tbl (Table_Name, Column_Name) 22 values (r.Table_Name, r.Column_Name); 23 24 exception 25 when others then 26 l_Err := sqlerrm; 27 insert into Log_tbl (Table_Name, Column_Name, Msg, Error_Flag) 28 values (r.Table_Name, r.Column_Name, l_Err, 'F'); 29 end; 30 31 commit; 32 33 end loop; 34 35 end; 36 / PL/SQL procedure successfully completed. SQL> select table_name, column_name, char_used 2 from user_tab_columns 3 where table_name in ('T1','T2', 'T3') 4 / TABLE_NAME COLUMN_NAME C ------------------------------ ------------------------------ - T1 A C T2 A C SQL> select table_name,column_name,error_flag 2 from log_tbl; TABLE_NAME COLUMN_NAME E --------------- --------------- - T1 A P T2 A P SQL> create table t3 (a varchar2(20) ) 2 / Table created. SQL> insert into t3 (a) values ('Hello') 2 / 1 row created. SQL> declare 2 l_Err varchar2(200); 3 begin 4 for r in (select atc.table_name, atc.column_name, atc.data_length 5 from user_tab_columns atc -- You would probably use ALL_ 6 left outer join Log_Tbl lt on (atc.Table_name = lt.Table_Name 7 and atc.Column_name = lt.Column_Name 8 and lt.Error_Flag = 'P') 9 where atc.data_type = 'VARCHAR2' 10 and atc.char_used = 'B' 11 and atc.Table_Name in ('T1', 'T2', 'T3')) loop 12 13 begin 14 execute immediate 'alter table ' || r.table_name 15 || ' modify ' 16 || r.column_name 17 || ' varchar2(' 18 || r.data_length 19 || ' char)'; 20 21 insert into Log_tbl (Table_Name, Column_Name) 22 values (r.Table_Name, r.Column_Name); 23 24 exception 25 when others then 26 l_Err := sqlerrm; 27 insert into Log_tbl (Table_Name, Column_Name, Msg, Error_Flag) 28 values (r.Table_Name, r.Column_Name, l_Err, 'F'); 29 end; 30 31 commit; 32 33 end loop; 34 35 end; 36 / PL/SQL procedure successfully completed. SQL> select table_name, column_name, char_used 2 from user_tab_columns 3 where table_name in ('T1','T2', 'T3') 4 / TABLE_NAME COLUMN_NAME C --------------- --------------- - T1 A C T2 A C T3 A C
-
convert bytes MB with PHP getSize
I thought I had cracked the nut of a previous debate.
http://forums.Adobe.com/message/4741283#4741283
A file works fine on my local test server. But on the remote site, the results are an unsorted mess.
I found a script that handles this pretty well.
<? PHP
class SortingIterator implements IteratorAggregate
{
private $iterator = null;
public function __construct (Traversable $iterator, $callback)
{
If (! is_callable ($callback)) {}
throw new InvalidArgumentException ("given callback is not callable!'");
}
$array = iterator_to_array ($iterator);
usort ($array, $callback);
$this-> iterator = new ArrayIterator ($array);
}
public void getIterator()
{
Return $this-> iterator;
}
}
? >
<! - results - >
< ul >
<? PHP
function mysort ($a, $b)
{
return $a-> getPathname() > $b-> getPathname().
}
$it = new SortingIterator (new RecursiveIteratorIterator (new RecursiveDirectoryIterator ("PATH/MY_DIRECTORY'")), "mysort");
{foreach ($it as $file)
echo "" < li > < a href = "". $file. « « > ». $file-> getFilename(). "< /a > -". $file-> getSize().' bytes < /li > ';
}
? >
< /ul >
All I need now is a simple way to convert results getSize bytes in MB.
Any ideas?
Thank you
Nancy O.
Use the round() php function
http://www.php.net/manual/en/function.round.php
round (file-> getSize() / 1048576, 2)
-
Byte [] convert bitmap in OS 5.0
I want to convert byte [] bitmap in OS 5.0
Please someone help me
Hi @ahmednaserfinal
See this link:
E.
-
Convert InputStream into byte array
Hey everybody,
I really need help with this problem that I can not get rid! I am doing an application that loads an image saved on the BB device and sends it to a server, the problem is we can send only a byte [].
So I try to apply the following method:
-Loading the image via the FileConnection class
-Open an InputStream from the FileConnection said
-Convert an array of bytes as InputStream
The code should look like this I guess:
FileConnection file = (FileConnection) Connector.open ("Original_SealV.jpg");
InputStream is = file.openInputStream ();Byte [] img = null;
int temp = is.read ();
{while(Temp>0)}Convert bytes here?
}
This is the last step I'm missing, I tried several methods, but could not run, so I beg for a bit of the collective wisdom of these forums...
Could someone help me? I will not forget the congratulations!
or you can always use the standard API
Byte [] buf = IOUtilities.streamToBytes (stream);
-
How to convert an array of char byte array?
Hello
Someone can say, how can I convert Byte char []?
Thank you
What:
data Byte [] =...
Char [] charArr = (new String (data)) .toCharArray ();
Rab
-
Convert size in bytes in human readable size unit
11.2.0.2 RDBMS
Hi all
Is there any function on Oracle to convert bytes into human readable?
Give a number in bytes, that this number is converted in kilobytes or megabytes the gigabytes and so on.
Thank you guys.
CREATE THE FUNCTION HDATA_SIZE)
p_bytes in NUMBERS
p_decimal IN DEFAULT NUMBER 0)
RETURN VARCHAR2
AS
HBYTES VARCHAR2 (80);
BEGIN
HBYTES: = BOX
WHEN p_bytes BETWEEN 0 AND 1023 CAN p_bytes | "Bytes
WHEN p_bytes< power(1024,2)="" then="" round(p_bytes="" 1024,p_decimal)="" ||'="">
WHEN p_bytes< power(1024,3)="" then="" round(p_bytes="" power(1024,2),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,4)="" then="" round(p_bytes="" power(1024,3),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,5)="" then="" round(p_bytes="" power(1024,4),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,6)="" then="" round(p_bytes="" power(1024,5),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,7)="" then="" round(p_bytes="" power(1024,6),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,8)="" then="" round(p_bytes="" power(1024,7),p_decimal)="" ||'="">
WHEN p_bytes< power(1024,9)="" then="" round(p_bytes="" power(1024,8),p_decimal)="" ||'="">
ON THE OTHER
"Invalid value for bytes.
END;
RETURN HBYTES;
END;
SELECT BYTES,
CASE
WHEN BETWEEN 0 AND 1023 BYTES CAN p_bytes | "Bytes
WHEN BYTES< power(1024,2)="" then="" round(bytes="" 1024,2)="" ||'="">
WHEN BYTES< power(1024,3)="" then="" round(bytes="" power(1024,2),2)="" ||'="">
WHEN BYTES< power(1024,4)="" then="" round(bytes="" power(1024,3),2)="" ||'="">
WHEN BYTES< power(1024,5)="" then="" round(bytes="" power(1024,4),2)="" ||'="">
WHEN BYTES< power(1024,6)="" then="" round(bytes="" power(1024,5),2)="" ||'="">
WHEN BYTES< power(1024,7)="" then="" round(bytes="" power(1024,6),2)="" ||'="">
WHEN BYTES< power(1024,8)="" then="" round(bytes="" power(1024,7),2)="" ||'="">
WHEN BYTES< power(1024,9)="" then="" round(bytes="" power(1024,8),2)="" ||'="">
ON THE OTHER
"Invalid value for bytes.
END;
HUMAN_SIZE,
HDATA_SIZE (BYTES) FUNC_BYTES,
HDATA_SIZE(BYTES,2) FUNC_BYTES_ROUND_2
OF BYTES_CONVERSION;
"BYTES." 'HUMAN_SIZE '. 'FUNC_BYTES '. 'FUNC_BYTES_ROUND_2 '. 48743068764242424 "43,29 PB" "PB 43. "43,29 PB" 2052456451442442 "PB OF 1.82. "2 PB. "PB OF 1.82. 1456842042452424 "PB OF 1.29. "1 PB. "PB OF 1.29. 140018974724255 "127,35 TB" "127 TB" "127,35 TB" 1380345446444 "1.26 TB" "1 TB. "1.26 TB" 11682705691 "10,88 GB" "11-GO" "10,88 GB" 9419054298 "8,77 GB" '9 GB' "8,77 GB" 4928925707 "4.59 GB" "5 GB" "4.59 GB" 4734365808 "4.41 GB" "4 GB" "4.41 GB" 2996172607 "2.79 GB" "3 GB" "2.79 GB" 2996161255 "2.79 GB" "3 GB" "2.79 GB" 2239299702 "2.09 GB" "2 GB" "2.09 GB" 2239294829 "2.09 GB" "2 GB" "2.09 GB" 1092878347 "1.02 GB" "1 GB". "1.02 GB" 1034780683 "986,84 MB" "987 MB" "986,84 MB" 902561803 "860,75 MB" "861 MB" "860,75 MB" 710223170 "677,32 MB" "677 MB" "677,32 MB" 700729988 "668,27 MB" "668 MB" "668,27 MB" 700598916 "668,14 MB" "668 MB" "668,14 MB" 631504907 "602,25 MB" "602 MB" "602,25 MB" Editada por Mensagem: bytes-13728488
-
Hello
I have a request. I have a MSSQL database into two columns. One is a varchar and the second is the Image type. I would use these two fields filled to KSOAP2. I tried to send a picture in KSOAP byte array but it did not, probably, I sometimes confuse.
Here is the source code.public byte[] getBytesFromBitmap(Bitmap bmp) { try { int height=bmp.getHeight(); int width=bmp.getWidth(); int[] rgbdata = new int[width*height]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); bmp.getARGB(rgbdata,0,width,0,0,width,height); for (int i = 0; i < rgbdata.length ; i++) { if (rgbdata[i] != -1) { dos.writeInt(i); dos.flush(); //l++; } } bos.flush(); return bos.toByteArray(); } catch (Exception ex) { Dialog.alert("getBytesFromBitmap: " + ex.toString()); return null; } } Bitmap borderBitmap = Bitmap.getBitmapResource("rounded.png"); byte[] img = getBytesFromBitmap(borderBitmap); String name = "Name"; SoapObject rpc = new SoapObject(serviceNamespace, "name"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); rpc.addProperty("_img", img); rpc.addProperty("_string", name); envelope.setOutputSoapObject(rpc); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.encodingStyle = SoapSerializationEnvelope.XSD;
I also tried... I transferred the image in the array of bytes to a string, using the string, I sent KSOAP and everything went well... The problem was that if she string converted to array of bytes, and then in a Bitmap, then bb do not show Bitmap. I would like to send a byte array.
Thank you
Stepan
This function is useful to get the bytes of the image.
public static byte[] returnByte(String path) { FileConnection fconn; int available = 0; InputStream input = null; byte[] data=null; try { fconn = (FileConnection)Connector.open(path); if(fconn.exists()==true) { input = fconn.openInputStream(); available = input.available(); int fSz = (int)fconn.fileSize(); data = new byte[fSz]; input.read(data, 0, fSz); } } catch(Exception e) { Dialog.alert("Error"); } return data; }
Now you must do this:
Byte [] img = returnByte ("pawan.png");
rpc.addProperty("_img", Base64.encode(img));
I'm sure it works...
Thank you
Maybe you are looking for
-
FaceTime works on iMac 2007 with El Cap 10.11.4
I'm in Yosemite since my last attempt with El Cap lost 10.11.2 the FaceTime feature. This is now corrected in OS X 10.11.4 of El Capitan? I really like the day to El Cap, but was FaceTime work very someone out there would execute on an iMac 10.11.4
-
Flow 11: 11 stream Webcam blurry
I have a netbook HP flow 11 is in a State of almost nine. Everything is going well except the webcam product a blurred image, and there is change of color. for example, my light blue eyeglases gaze. I tried to install YouCam, but it is blurry, there
-
Looking for a waterproof/resistant case for my iPhone 6s Ant ideas?
looking for a waterproof/resistant case that doesn't see a ton. Any ideas? Thank you very much
-
I just bought a Probook s 4540, I tried to install a second 4g memory. When I looked I can't find a second slot. Is 8g the maximum memory that can be installed?
-
Hello What is the maxium size & speed of Ram my Intel HP Pavilion dv7-1262us can support? Any help is very appreciated. Thank you.