My image is unique size, the byte array is another?

I have a very similar problem, but no solution:

I need in png encode an Image which is 130 x 30 but the byteArray with which it was created is not long enough. I see it right in front of me.

<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:TitleWindow xmlns:mx = "http://www.adobe.com/2006/mxml"
Width = "160" height = "114" horizontalAlign = "center" >

< mx:Script >
<! [CDATA]
Import mx.core.Application;
Import mx.core.IFlexDisplayObject;
Import mx.graphics.codec.PNGEncoder;
Import mx.managers.PopUpManager;

private static var instance: Test = null;
private var strng:String ="";
private var png:ByteArray;
private var result: ByteArray;

public static void ready(str:String):void {}
If (instance == null) instance = new Test();
instance.strng = str;
instance. Show();
}

private void show(): void {}
result = stringToByteArray (strng);
If (! this.isPopUp) {}
setPopupHelpWindowStyle (this);
PopUpManager.addPopUp (this, Application.application as DisplayObject, false);
PopUpManager.centerPopUp (this);
}
IMG. Load (result);
}

private static void setPopupHelpWindowStyle(ifdo:IFlexDisplayObject): void {}
var isc:IStyleClient = IFlexDisplayObject (ifdo) as IStyleClient;
isc.setStyle ("modalTransparency", 1);
}

private static void stringToByteArray(str:String): ByteArray {}
var result: ByteArray = new ByteArray();
var i: int = 0;
While (I < str.length) {}
result.writeByte (number ("0 x" + str.substr (i, 2)));
I += 2;
}


return the result;
}

public void encode (): void {}
var encoder: PNGEncoder = new PNGEncoder;
instance.PNG = coder.encodeByteArray (instance.result, instance.img.width, instance.img.height);
}
[]] >
< / mx:Script >
< mx:Image id = "img" x = "10" y = "10" width = "130" height = "30" />
< mx:Button label = "Button" click = "encode ()" / >
< / mx:TitleWindow >

When I try to encode, I get:

: Error #2030: end of file was encountered.
at flash.utils::ByteArray/readUnsignedInt()

I get an error because Baker is created from a string that is only 3540 characters long, or only 1720 bytes. I can see the picture and he'd fill the whole box, but I don't know what type of alogorthm is used to extend the byteArray to fill.

Is there a method to access the pixels of the image similar to the BitmapData feature, where I can browse the pixels and read the bits directly from the display to build a new ByteArray? Or a way to make a bitmapdata object?


var bmd:BitmapData = ?;
var useableByteArray:ByteArray = new ByteArray();

for (var i: int = 0; i < img.width; i ++) {}
for (var j: int = 0; j < img.height; j ++) {}
useableByteArray.writeByte (bmd.getPixel32 (i, j));
}
}

Post edited by: eboda_kcuf

Can use BItmapData.draw () on the Image?

Tags: Flex

Similar Questions

  • several images capture and read their path to send the byte array to the web service

    Hello

    Have a problem when the image capture, the requirement is to open the camera and capture multiple images, and once done it should send the array of bytes to the web service, wrote the class with reader and Video Control of the code and then using the saved file to store image API, but when the user capture multiple images it replaces previous if I keep the path to say dynamic by using the date and time then how I just know what images are recently captured and their path, one time I know that the path of recently captured using new fileconnection images can read the image byte array.

    Hi Nishant,

    find the attached code. In this demo, you will find:

    (1) the use of the listner log file system

    (2) how to move data from one folder to another.

    (3) how to read file system byteArray.

  • How to get the byte Array of image cascading?

    Hello

    I need help to get the array of bytes to the image.

    In fact, I have developed image processing application so I need.

    Thank you.

    Please ask a feature against Blackberry 10 (BBTEN) in the Issue Tracker: http://supportforums.blackberry.com/t5/Java-Development/Developer-Issue-Tracker/td-p/271768

    Stuart

  • Replace the byte array

    Hi all

    Please see my attached code, where I receive serial data, turn it into an array of bytes and you want to use a state machine in order to to treat.

    I wrote the data in a table, and it also displays via an indicator in the chain. So that the data on the screen, I used a feedback node. However, this means that the data are added each time it is sent (at intervals of 10 seconds). How can I get the data on the screen when sending and then be written when new data are received, both in the indicator and the table?

    Thank you

    Richard.


  • Move the RAID5 array to another server

    Had a RAID failure on an old PE2850. looked like two disks of default at the same time, which makes me suspect the PERC, not drives - especially because I moved the disks as a unit to another PE2850 and was able to mount it as a second table RAID (the new server OS on disk RAID1 disks 0 and 1, this table 2-5) and he acknowledged the table.

    However, I can't mount a Windows partition.  I start the operating system on the new server and Disk Manager recognizes there is a drive, but I can't use it unless I format it, who will become the object of all the activity, which is at this stage to draw sort of useful data in the coast of the Bay.

    Anyone can suggest a way to get this recognized by a new server table or card PERC or something?

    You would be able to connect to a PERC 4 controller, otherwise it will not recognize the VD.

    You could try editing under linux... sometimes that has a better tolerance (or the less different) for corrupted partitions/file systems. If the table of partition/filesystem is corrupted, you can also try the tools to try to fix it. If the damage is superficial, as they often work.

    You said that you had two disks fail... describe how you got the table online. It is important and can determine whether or not the other attempts to retrieve data are futile.

  • Sending the image byte array

    Hello friends

    Please guide me how can I send a table yte my UIcopmonent bitmap with the size of the 0.4 scale.

    In fact my my UIComponet size is 234 X 390 and I hv to send the byte array to the PHP end with size 90 X 150.

    This is so, how can I draw an image with the smallest size.please guide me almost 0.4 scale image.

    When I usedthis code

    var bmd:BitmapData = new BitmapData(cnvParent.width,cnvParent.height,true,0xffffff);
    var mt:Matrix new matrix());
    Mt.Scale (.4,.4);
    BMD. Draw (cnvParent, MT);
    var jpgencoder:PNGEncoder = new PNGEncoder();
    byteArray = jpgencoder.encode (bmd);

    It shows nothing after conversion to byte array. Please help me out of this problem, I have confused mtotally

    Thanks and greetings

    Vineet osho

    Hello

    If you acknowledged the answers when given to previous requests for help may call a friend people would sound more sincere. You where showed how scaling of images already was what process does not?

    David.

  • Numbers of string to byte array

    I try to use "Byte array to string" if I display the byte array, I can see the last two items are the numbers 4-8 (ASCII 52 56) but when I use the "Byte Array to necklace" and add an indicator of the 48 is missing?  Ignore this palette number 0-9?  Is there another way to easily convert an array of bytes into a string with numbers.  What I am doing wrong?

    I'm looking, but I can't believe I can't find an example of this?


  • Generate PrivateKey using byte array

    Hello

    I'm working on my school project, where I should simulate the DDA authentication. I placed my public and private keys inside byte [] variables in the applet, and in order to encrypt and decrypt messages I need to convert these arrays of bytes to the PublicKey and PrivateKey objects. I know that javacard.security defines a key factory class keyBuilder, but I can't understand how to use this class, to rebuild my keys, which are in the byte array. Is there a way to do this?

    Thank you
    Vuk

    hem. toString? a string? JavaCard know only 8 and 16-bit atomic types and tables. No int. No tank. No java.lang.String.

    How long have you studied javacard?

    the offcard entity will get the keys in arrays of bytes, put them in APDU, send the APDU to the javacard inside the map applet using javax.smartcardio. the javacard applet will then store the buffers received in key forums.

    I think you're mixing offcard code of java and applet javacard "at a distance". There is no magical conduit between java objects and plastic in a card; you need to send APDU commands to the cmdlet to store your keys inside the applet. This means developing a bunch of javacard code that will run in the map, using GlobalPlatform to download the code of the card.

    See here for pointers to base on the map technology.
    APDU and contactless

    Best regards and good luck.

  • working capital with images of different sizes in the table

    Hello, I have a table with images of different size.  I want to use a bearing on each Panel, but my image is not the same size.  When I roll over the image the first image disappears.  Any suggestions?  I use CS5.5 Show map to the bottom.of page.

    Kappa Delta Pi

    Thank you

    Also I have never been able to use the "Preview in browser" globe icon  I don't seem to be, any suggestions on how to add this?

    A very simple solution is to make a second image that contains the image superimposed on the map. You must have 4 total images for this (all images have the same size):

    1. the plan with no photos

    2 - 4. The card with a unique image on the desired region (i.e., 3 additional images).

    In your access points, you exchange the entire map with the map of the desired region.

  • For an IMAQ image, how is calculated the size of the area of alignment to the left or to the right?

    For an IMAQ image, how is calculated the size of the area of alignment to the left or to the right? My initial assumption of the diagram

    http://zone.NI.com/reference/en-XX/help/370281M-01/imaqvision/imaq_getimagepixelptr/

    is that the left and right are equal. But that doesn't seem to be the case. Can someone tell me the magic formula? A combination of the border width and the width of the image?

    Thank you...

    Andrew

    Andrew_Scott_SPCi.ca wrote:

    All this appeared when I relalized that the mapss Pixel pointer the value 0,0 point of the image, not the point 0,0 of the largest container with areas of alignment and borders. Would be nice if the drawing in the documentation put it.

    This described in help, is not?

    Andrey.

  • How to find the size of an array?

    Ideally, it could be the size of an array is created but I will work with existing vi, and this seems an important piece of information.

    For example, with automatic indexing on, I said that the index of a loop For (for example) will be based on the "size of the table' rather than the value specified to connect N.

    I see that the size of an array expands as data is added manually.  Does this mean that the picture is sized to the value of the Index by the first entry of NULL?

    In this case, a table would be able to contain a Null value (if Null means in this context)?

    There is a primitive 'size chart' in the table palette. The size of the table in not bound the number of visible elements on the façade.

    wildcatherder wrote:

    For example, with automatic indexing on, I said that the index of a loop For (for example) will be based on the "size of the table' rather than the value specified to connect N.

    This is incorrect. The iteration will be based on the smaller of the following numbers: Wired n size, size of entries in table aotoindexing.

    So if wire you a zero to N, the loop will not iterate, no matter how big the autoindexing tables are. In more recent versions of LabVIEW, the loop cal FOR terminate early (if you enable the conditional terminal).

  • Retrieve the bytes of the image of the path of the image file

    Hello

    I was unable to find a post that details how to retrieve the bytes of the image of an image (given the path to the file of the image on the device).  Basically, using the FilePicker, I'm able to get the path of an image chosen by the user:

    There you go:

    Pass just your file as method parameter name.

     public static byte[] getBytesFromFile(String filename) throws IOException {
            FileConnection fconn = null;
            InputStream is = null;
            try {
                fconn = (FileConnection) Connector.open(filename, Connector.READ);
                is = fconn.openInputStream();
    
                return IOUtilities.streamToBytes(is);
            } finally {
                if (is != null) {
                    is.close();
                }
                if (fconn != null) {
                    fconn.close();
                }
            }
        }
    
  • What is the size of the image used to render the list (for list image rendering)?

    Hello!

    Can u please tell me, what is the size of the image used to represent the listItem. I used the size 40 x 40 for listitems, but the listitem be merged with another. Image will not be rendered with the size (actual size).

    PLS, suggest me-

    ListIField generally uses a height up to the police on the storm no devices. The storm, it has a fixed size greater than the height of the font.

    If you want to draw a picture of 40 x 40, you need minimum height of 40px. Call setRowHeight (40) in the constructor of the listfield.

  • Change the size extraction sql array by query or the worksheet

    I have a function table in pipeline, used for debugging, which performs work on a potentially long period of time where the line of conduct is called periodically throughout the performance.

    If the preferences for the sql fetch size table is set to 1, then the result tab displays each line as it is channeled on which is exactly what I want.

    For general development, I prefer a value of 500.

    Is it possible to set this value in a SQL worksheet so that I don't have to navigate the window preferences and then reset my connection?

    I tried to use the SQL * set arraysize, but that had no effect on the results of query and executed as a script window was not helpful either.

    Is it possible to set this value in a SQL worksheet

    No, not currently.  The Sql Array Fetch size preference applies to all connections.  Looks like a developer once thought about changing this preference value whenever The VALUE ARRAYSIZE runs in a spreadsheet, but decided in the end not too - what is needed is a fetch size property with a scope at the connection level or even the level of the worksheet. Since a spreadsheet can use a connection that is not shared, which would give users precise control.

    You might want to add this as a feature on the SQL Developer Exchange request: http://sqldeveloper.oracle.com/

    Of course, it is not necessary to re-establish a connection to pick up this change of preference, but in fact can work that way in some cases.  I could be wrong, but probably result grids will pick up the new value without a reset of the connection.

    Kind regards

    Gary

    SQL development team

  • With previous versions, I could press control (mac) and click on a layer, and he would choose this graph, what form it was. Then I could go to image-culture and reframe the entire file down to that size. Now, this feature is missing. What is the new way t

    With previous versions, I could press control (mac) and click on a layer, and he would choose this graph, what form it was. Then I could go to image-culture and reframe the entire file down to that size. Now, this feature is missing. What is the new way to do this?

    This is the command key, not the control key for a Mac that you use on the layer.

    Gene

Maybe you are looking for