Search Results

Search found 3923 results on 157 pages for 'binary'.

Page 10/157 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Reverse reading WORD from a binary file?

    - by Angel
    Hi, I have a structure: struct JFIF_HEADER { WORD marker[2]; // = 0xFFD8FFE0 WORD length; // = 0x0010 BYTE signature[5]; // = "JFIF\0" BYTE versionhi; // = 1 BYTE versionlo; // = 1 BYTE xyunits; // = 0 WORD xdensity; // = 1 WORD ydensity; // = 1 BYTE thumbnwidth; // = 0 BYTE thumbnheight; // = 0 }; This is how I read it from the file: HANDLE file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); DWORD tmp = 0; DWORD size = GetFileSize(file, &tmp); BYTE *DATA = new BYTE[size]; ReadFile(file, DATA, size, &tmp, 0); JFIF_HEADER header; memcpy(&header, DATA, sizeof(JFIF_HEADER)); This is how the beginning of my file looks in hex editor: 0xFF 0xD8 0xFF 0xE0 0x00 0x10 0x4A 0x46 0x49 0x46 0x00 0x01 0x01 0x00 0x00 0x01 When I print header.marker, it shows exactly what it should (0xFFD8FFE0). But when I print header.length, it shows 0x1000 instead of 0x0010. The same thing is with xdensity and ydensity. Why do I get wrong data when reading a WORD? Thank you.

    Read the article

  • Return parent of node in Binary Tree

    - by user188995
    I'm writing a code to return the parent of any node, but I'm getting stuck. I don't want to use any predefined ADTs. //Assume that nodes are represented by numbers from 1...n where 1=root and even //nos.=left child and odd nos=right child. public int parent(Node node){ if (node % 2 == 0){ if (root.left==node) return root; else return parent(root.left); } //same case for right } But this program is not working and giving wrong results. My basic algorithm is that the program starts from the root checks if it is on left or on the right. If it's the child or if the node that was queried else, recurses it with the child.

    Read the article

  • Write to a binary file?

    - by rick irby
    Here is data structure w/ variables: struct Part_record { char id_no[3]; int qoh; string desc; double price: }; --- (Using "cin" to input data) --- Part_record null_part = {" ", 0," ",0.0}; --- --- file.seekg( -(long)sizeof(Part_record), ios::cur); file.write( ( char *)&part, sizeof(Part_record) ); The three variables, qoh, Id_no & price, write out correctly, but the "desc" variable is not right. Do I need to initialize Part_record some other way? It should be 20 characters in length. If you have enough info here, pls share your advice,thanks.

    Read the article

  • findNode in binary search tree

    - by Weadadada Awda
    Does this look right? I mean I am trying to implement the delete function. Node* BST::findNode(int tofind) { Node* node = new Node; node = root; while (node != NULL) { if (node->val == tofind) { return node; } else if (tofind < node->val) { node = node->left; } else { node = node->right; } } } Here is the delete, it's not even close to done but, void BST::Delete(int todelete) { // bool found = false; Node* toDelete = new Node(); toDelete=findNode(todelete); if(toDelete->val!=NULL) { cout << toDelete->val << endl; } } This causes a segmentation fault just running that, any ideas?

    Read the article

  • .NET binary serialization conditionally without ISerializable

    - by SillyWhy
    I got 2 classes, for example: public class A { private B b; ... } public class B { ... } I need to serialize an object A using BinaryFormatter. When remoting it shall include the field b, but not when serialize to file. Here is what I added: [Serializable] public class A : MarshalByRefObject { private B b; [OnSerializing] private void OnSerializing(StreamingContext context) { if (context.State == StreamingContextStates.File) { this.b = null; } } ... } [Serializable] public class B : MarshalByRefObject { ... } I think this is a bad design because if another class C also contains B, in class C we must add the duplicate OnSerializing() logic as in A. Class B should decide what to do, not class A or C. I don't want to use ISerializable interface because there are too many variables in class B have to be added to SerializationInfo. I can create a SerializationSurrogate for class B, which perform nothing in GetObjectData() & SetObjectData(), then use it when serializing to file. However the same maintenance issue because whoever modify class B can't notice what going to happen during serialization & the existence of SerializationSurrogate. Is there a better alternative?

    Read the article

  • Error inserting data in binary tree

    - by chepe263
    I copied this code (in spanish) http://www.elrincondelc.com/nuevorincon/index.php?pag=codigos&id=4 and wrote a new one. This is my code: #include <cstdlib> #include <conio.h> #include <iostream> using namespace std; struct nodoarbol { int dato; struct nodoarbol *izq; struct nodoarbol *der; }; typedef nodoarbol Nodo; typedef Nodo *Arbol; void insertar(Arbol *, int); void inorden(Arbol); void postorden(Arbol); void preorden(Arbol); void insertar(Arbol *raiz, int nuevo){ if (*raiz==NULL){ *raiz = (Nodo *)malloc(sizeof(Nodo)); if (*raiz != NULL){ (*raiz)->dato=nuevo; (*raiz)->der=NULL; (*raiz)->izq=NULL; } else{ cout<<"No hay memoria suficiente u ocurrio un error"; } } else{ if (nuevo < (*raiz)->dato) insertar( &((*raiz)->izq), nuevo ); else if (nuevo > (*raiz)->dato) insertar(&((*raiz)->der), nuevo); } }//inseertar void inorden(Arbol raiz){ if (raiz != NULL){ inorden(raiz->izq); cout << raiz->dato << " "; inorden(raiz->der); } } void preorden(Arbol raiz){ if (raiz != NULL){ cout<< raiz->dato << " "; preorden(raiz->izq); preorden(raiz->der); } } void postorden(Arbol raiz){ if (raiz!=NULL){ postorden(raiz->izq); postorden(raiz->der); cout<<raiz->dato<<" "; } } int main() { int i; i=0; int val; Arbol raiz = NULL; for (i=0; i<10; i++){ cout<<"Inserte un numero"; cin>>val; insertar( (raiz), val); } cout<<"\nPreorden\n"; preorden(raiz); cout<<"\nIneorden\n"; inorden(raiz); cout<<"\nPostorden\n"; postorden(raiz); return 0; } I'm using netbeans 7.1.1, mingw32 compiler This is the output: make[2]: Leaving directory `/q/netbeans c++/NetBeansProjects/treek' make[1]: Leaving directory `/q/netbeans c++/NetBeansProjects/treek' main.cpp: In function 'int main()': main.cpp:110:30: error: cannot convert 'Arbol {aka nodoarbol*}' to 'Nodo** {aka nodoarbol**}' for argument '1' to 'void insertar(Nodo**, int)' make[2]: *** [build/Release/MinGW-Windows/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 11s) I don't understand what's wrong since i just copied the code (and rewrite it to my own code). I'm really good in php, asp.net (vb) and other languages but c is a headche for me. I've been struggling with this problem for about an hour. Could somebody tell me what could it be?

    Read the article

  • Binary Search Tree can't delete the root

    - by Ali Zahr
    Everything is working fine in this function, but the problem is that I can't delete the root, I couldn't figure out what's the bug here.I've traced the "else part" it works fine until the return, it returns the old value I don't know why. Plz Help! node *removeNode(node *Root, int key) { node *tmp = new node; if(key > Root->value) Root->right = removeNode(Root->right,key); else if(key < Root->value) Root->left = removeNode(Root->left, key); else if(Root->left != NULL && Root->right != NULL) { node *minNode = findNode(Root->right); Root->value = minNode->value; Root->right = removeNode(Root->right,Root->value); } else { tmp = Root; if(Root->left == NULL) Root = Root->right; else if(Root->right == NULL) Root = Root->left; delete tmp; } return Root; }

    Read the article

  • Better way to download a binary file?

    - by geoff
    I have a site where a user can download a file. Some files are extremely large (the largest being 323 MB). When I test it to try and download this file I get an out of memory exception. The only way I know to download the file is below. The reason I'm using the code below is because the URL is encoded and I can't let the user link directly to the file. Is there another way to download this file without having to read the whole thing into a byte array? FileStream fs = new FileStream(context.Server.MapPath(url), FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(context.Server.MapPath(url)).Length; byte[] bytes = br.ReadBytes((int) numBytes); string filename = Path.GetFileName(url); context.Response.Buffer = true; context.Response.Charset = ""; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); context.Response.ContentType = "application/x-rar-compressed"; context.Response.AddHeader("content-disposition", "attachment;filename=" + filename); context.Response.BinaryWrite(bytes); context.Response.Flush(); context.Response.End();

    Read the article

  • efficient video format/codec for sparse & binary blob tracking

    - by user391339
    I am working on a blob tracking project and have many high-definition videos that I would like to reduce in size for storage and downstream tracking/shape-analysis. I want to use a lossless method that takes advantage of the black and white nature of the video as well as the fact that not much is moving between individual frames. The videos are quite sparse, with 5 to 10 b&w blobs per frame occupying <30% of the space in total, with each blob moving <5-10% of the field of view between frames and not changing shape too much between 2-3 frames. I will work in Python, Matlab, or LabView for this project, and could use a batch utility if available. It may be worthwhile to export the files as compressed image stacks if a proper video format can't be found. What are the pros and cons of this? A video codec uses correlations between neighboring frames, so it should be more efficient, but not if the wrong one is chosen or if it is improperly configured.

    Read the article

  • How many posibilities on a binary ?

    - by Val
    in hexadecimal "10 10 10 10" system you have 0-255 posibilities right? in total 256 different posibilities as there are 8 1s and 0s. how many different posibilities would i get? if i had 10 digits. instead of 8? or how would i calculate that in php ?

    Read the article

  • Problems in Binary Search Tree

    - by user2782324
    This is my first ever trial at implementing the BST, and I am unable to get it done. Please help The problem is that When I delete the node if the node is in the right subtree from the root or if its a right child in the left subtree, then it works fine. But if the node is in the left subtree from root and its any left child, then it does not get deleted. Can someone show me what mistake am I doing?? the markedNode here gets allocated to the parent node of the node to be deleted. the minValueNode here gets allocated to a node whose left value child is the smallest value and it will be used to replace the value to be deleted. package DataStructures; class Node { int value; Node rightNode; Node leftNode; } class BST { Node rootOfTree = null; public void insertintoBST(int value) { Node markedNode = rootOfTree; if (rootOfTree == null) { Node newNode = new Node(); newNode.value = value; rootOfTree = newNode; newNode.rightNode = null; newNode.leftNode = null; } else { while (true) { if (value >= markedNode.value) { if (markedNode.rightNode != null) { markedNode = markedNode.rightNode; } else { Node newNode = new Node(); newNode.value = value; markedNode.rightNode = newNode; newNode.rightNode = null; newNode.leftNode = null; break; } } if (value < markedNode.value) { if (markedNode.leftNode != null) { markedNode = markedNode.leftNode; } else { Node newNode = new Node(); newNode.value = value; markedNode.leftNode = newNode; newNode.rightNode = null; newNode.leftNode = null; break; } } } } } public void searchBST(int value) { Node markedNode = rootOfTree; if (rootOfTree == null) { System.out.println("Element Not Found"); } else { while (true) { if (value > markedNode.value) { if (markedNode.rightNode != null) { markedNode = markedNode.rightNode; } else { System.out.println("Element Not Found"); break; } } if (value < markedNode.value) { if (markedNode.leftNode != null) { markedNode = markedNode.leftNode; } else { System.out.println("Element Not Found"); break; } } if (value == markedNode.value) { System.out.println("Element Found"); break; } } } } public void deleteFromBST(int value) { Node markedNode = rootOfTree; Node minValueNode = null; if (rootOfTree == null) { System.out.println("Element Not Found"); return; } if (rootOfTree.value == value) { if (rootOfTree.leftNode == null && rootOfTree.rightNode == null) { rootOfTree = null; return; } else if (rootOfTree.leftNode == null ^ rootOfTree.rightNode == null) { if (rootOfTree.rightNode != null) { rootOfTree = rootOfTree.rightNode; return; } else { rootOfTree = rootOfTree.leftNode; return; } } else { minValueNode = rootOfTree.rightNode; if (minValueNode.leftNode == null) { rootOfTree.rightNode.leftNode = rootOfTree.leftNode; rootOfTree = rootOfTree.rightNode; } else { while (true) { if (minValueNode.leftNode.leftNode != null) { minValueNode = minValueNode.leftNode; } else { break; } } // Minvalue to the left of minvalue node rootOfTree.value = minValueNode.leftNode.value; // The value has been swapped if (minValueNode.leftNode.leftNode == null && minValueNode.leftNode.rightNode == null) { minValueNode.leftNode = null; } else { if (minValueNode.leftNode.leftNode != null) { minValueNode.leftNode = minValueNode.leftNode.leftNode; } else { minValueNode.leftNode = minValueNode.leftNode.rightNode; } // Minvalue deleted } } } } else { while (true) { if (value > markedNode.value) { if (markedNode.rightNode != null) { if (markedNode.rightNode.value == value) { break; } else { markedNode = markedNode.rightNode; } } else { System.out.println("Element Not Found"); return; } } if (value < markedNode.value) { if (markedNode.leftNode != null) { if (markedNode.leftNode.value == value) { break; } else { markedNode = markedNode.leftNode; } } else { System.out.println("Element Not Found"); return; } } } // Parent of the required element found // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (markedNode.rightNode != null) { if (markedNode.rightNode.value == value) { if (markedNode.rightNode.rightNode == null && markedNode.rightNode.leftNode == null) { markedNode.rightNode = null; return; } else if (markedNode.rightNode.rightNode == null ^ markedNode.rightNode.leftNode == null) { if (markedNode.rightNode.rightNode != null) { markedNode.rightNode = markedNode.rightNode.rightNode; return; } else { markedNode.rightNode = markedNode.rightNode.leftNode; return; } } else { if (markedNode.rightNode.value == value) { minValueNode = markedNode.rightNode.rightNode; } else { minValueNode = markedNode.leftNode.rightNode; } if (minValueNode.leftNode == null) { // MinNode has no left value markedNode.rightNode = minValueNode; return; } else { while (true) { if (minValueNode.leftNode.leftNode != null) { minValueNode = minValueNode.leftNode; } else { break; } } // Minvalue to the left of minvalue node if (markedNode.leftNode != null) { if (markedNode.leftNode.value == value) { markedNode.leftNode.value = minValueNode.leftNode.value; } } if (markedNode.rightNode != null) { if (markedNode.rightNode.value == value) { markedNode.rightNode.value = minValueNode.leftNode.value; } } // MarkedNode exchanged if (minValueNode.leftNode.leftNode == null && minValueNode.leftNode.rightNode == null) { minValueNode.leftNode = null; } else { if (minValueNode.leftNode.leftNode != null) { minValueNode.leftNode = minValueNode.leftNode.leftNode; } else { minValueNode.leftNode = minValueNode.leftNode.rightNode; } // Minvalue deleted } } } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (markedNode.leftNode != null) { if (markedNode.leftNode.value == value) { if (markedNode.leftNode.rightNode == null && markedNode.leftNode.leftNode == null) { markedNode.leftNode = null; return; } else if (markedNode.leftNode.rightNode == null ^ markedNode.leftNode.leftNode == null) { if (markedNode.leftNode.rightNode != null) { markedNode.leftNode = markedNode.leftNode.rightNode; return; } else { markedNode.leftNode = markedNode.leftNode.leftNode; return; } } else { if (markedNode.rightNode.value == value) { minValueNode = markedNode.rightNode.rightNode; } else { minValueNode = markedNode.leftNode.rightNode; } if (minValueNode.leftNode == null) { // MinNode has no left value markedNode.leftNode = minValueNode; return; } else { while (true) { if (minValueNode.leftNode.leftNode != null) { minValueNode = minValueNode.leftNode; } else { break; } } // Minvalue to the left of minvalue node if (markedNode.leftNode != null) { if (markedNode.leftNode.value == value) { markedNode.leftNode.value = minValueNode.leftNode.value; } } if (markedNode.rightNode != null) { if (markedNode.rightNode.value == value) { markedNode.rightNode.value = minValueNode.leftNode.value; } } // MarkedNode exchanged if (minValueNode.leftNode.leftNode == null && minValueNode.leftNode.rightNode == null) { minValueNode.leftNode = null; } else { if (minValueNode.leftNode.leftNode != null) { minValueNode.leftNode = minValueNode.leftNode.leftNode; } else { minValueNode.leftNode = minValueNode.leftNode.rightNode; } // Minvalue deleted } } } } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } } } } } public class BSTImplementation { public static void main(String[] args) { BST newBst = new BST(); newBst.insertintoBST(19); newBst.insertintoBST(13); newBst.insertintoBST(10); newBst.insertintoBST(20); newBst.insertintoBST(5); newBst.insertintoBST(23); newBst.insertintoBST(28); newBst.insertintoBST(16); newBst.insertintoBST(27); newBst.insertintoBST(9); newBst.insertintoBST(4); newBst.insertintoBST(22); newBst.insertintoBST(17); newBst.insertintoBST(30); newBst.insertintoBST(40); newBst.deleteFromBST(5); newBst.deleteFromBST(4); newBst.deleteFromBST(9); newBst.deleteFromBST(10); newBst.deleteFromBST(13); newBst.deleteFromBST(16); newBst.deleteFromBST(17); newBst.searchBST(5); newBst.searchBST(4); newBst.searchBST(9); newBst.searchBST(10); newBst.searchBST(13); newBst.searchBST(16); newBst.searchBST(17); System.out.println(); newBst.deleteFromBST(20); newBst.deleteFromBST(23); newBst.deleteFromBST(27); newBst.deleteFromBST(28); newBst.deleteFromBST(30); newBst.deleteFromBST(40); newBst.searchBST(20); newBst.searchBST(23); newBst.searchBST(27); newBst.searchBST(28); newBst.searchBST(30); newBst.searchBST(40); } }

    Read the article

  • Command to find the source package of a binary?

    - by Delan Azabani
    I know there's a which command, that echoes the full name of a binary (e.g. which sh). However, I'm fairly sure there's a command that echoes the package that provides a particular binary. Is there such a command? If so, what is it? I'd like to be able to run this: commandName ls and get coreutils for example.

    Read the article

  • --log-slave-updates is OFF but updates received from master are still logged to slave binary log?

    - by quanta
    MySQL version 5.5.14 According to the document, by the default, slave does not log to its binary log any updates that are received from a master server. Here are my config. on the slave: # egrep 'bin|slave' /etc/my.cnf relay-log=mysqld-relay-bin log-bin = /var/log/mysql/mysql-bin binlog-format=MIXED sync_binlog = 1 log-bin-trust-function-creators = 1 mysql> show global variables like 'log_slave%'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | log_slave_updates | OFF | +-------------------+-------+ 1 row in set (0.01 sec) mysql> select @@log_slave_updates; +---------------------+ | @@log_slave_updates | +---------------------+ | 0 | +---------------------+ 1 row in set (0.00 sec) but slave still logs the updates that are received from a master to its binary logs, let's see the file size: -rw-rw---- 1 mysql mysql 37M Apr 1 01:00 /var/log/mysql/mysql-bin.001256 -rw-rw---- 1 mysql mysql 25M Apr 2 01:00 /var/log/mysql/mysql-bin.001257 -rw-rw---- 1 mysql mysql 46M Apr 3 01:00 /var/log/mysql/mysql-bin.001258 -rw-rw---- 1 mysql mysql 115M Apr 4 01:00 /var/log/mysql/mysql-bin.001259 -rw-rw---- 1 mysql mysql 105M Apr 4 18:54 /var/log/mysql/mysql-bin.001260 and the sample query when reading these binary files with mysqlbinlog utility: #120404 19:08:57 server id 3 end_log_pos 110324763 Query thread_id=382435 exec_time=0 error_code=0 SET TIMESTAMP=1333541337/*!*/; INSERT INTO norep_SplitValues VALUES ( NAME_CONST('cur_string',_utf8'118212' COLLATE 'utf8_general_ci')) /*!*/; # at 110324763 Did I miss something?

    Read the article

  • Understanding Application binary interface (ABI)

    - by Tim
    I am trying to understand the concept of Application binary interface (ABI). From The Linux Kernel Primer: An ABI is a set of conventions that allows a linker to combine separately compiled modules into one unit without recompilation, such as calling conventions, machine interface, and operating-system interface. Among other things, an ABI defines the binary interface between these units. ... The benefits of conforming to an ABI are that it allows linking object files compiled by different compilers. From Wikipedia: an application binary interface (ABI) describes the low-level interface between an application (or any type of) program and the operating system or another application. ABIs cover details such as data type, size, and alignment; the calling convention, which controls how functions' arguments are passed and return values retrieved; the system call numbers and how an application should make system calls to the operating system; and in the case of a complete operating system ABI, the binary format of object files, program libraries and so on. I was wondering whether ABI depends on both the instruction set and the OS. Are the two all that ABI depends on? What kinds of role does ABI play in different stages of compilation: preprocessing, conversion of code from C to Assembly, conversion of code from Assembly to Machine code, and linking? From the first quote above, it seems to me that ABI is needed for only linking stage, not the other stages. Is it correct? When is ABI needed to be considered? Is ABI needed to be considered during programming in C, Assembly or other languages? If yes, how are ABI and API different? Or is it only for linker or compiler? Is ABI specified for/in machine code, Assembly language, and/or of C?

    Read the article

  • Collaborative Whiteboard using WebSocket in GlassFish 4 - Text/JSON and Binary/ArrayBuffer Data Transfer (TOTD #189)

    - by arungupta
    This blog has published a few blogs on using JSR 356 Reference Implementation (Tyrus) as its integrated in GlassFish 4 promoted builds. TOTD #183: Getting Started with WebSocket in GlassFish TOTD #184: Logging WebSocket Frames using Chrome Developer Tools, Net-internals and Wireshark TOTD #185: Processing Text and Binary (Blob, ArrayBuffer, ArrayBufferView) Payload in WebSocket TOTD #186: Custom Text and Binary Payloads using WebSocket One of the typical usecase for WebSocket is online collaborative games. This Tip Of The Day (TOTD) explains a sample that can be used to build such games easily. The application is a collaborative whiteboard where different shapes can be drawn in multiple colors. The shapes drawn on one browser are automatically drawn on all other peer browsers that are connected to the same endpoint. The shape, color, and coordinates of the image are transfered using a JSON structure. A browser may opt-out of sharing the figures. Alternatively any browser can send a snapshot of their existing whiteboard to all other browsers. Take a look at this video to understand how the application work and the underlying code. The complete sample code can be downloaded here. The code behind the application is also explained below. The web page (index.jsp) has a HTML5 Canvas as shown: <canvas id="myCanvas" width="150" height="150" style="border:1px solid #000000;"></canvas> And some radio buttons to choose the color and shape. By default, the shape, color, and coordinates of any figure drawn on the canvas are put in a JSON structure and sent as a message to the WebSocket endpoint. The JSON structure looks like: { "shape": "square", "color": "#FF0000", "coords": { "x": 31.59999942779541, "y": 49.91999053955078 }} The endpoint definition looks like: @WebSocketEndpoint(value = "websocket",encoders = {FigureDecoderEncoder.class},decoders = {FigureDecoderEncoder.class})public class Whiteboard { As you can see, the endpoint has decoder and encoder registered that decodes JSON to a Figure (a POJO class) and vice versa respectively. The decode method looks like: public Figure decode(String string) throws DecodeException { try { JSONObject jsonObject = new JSONObject(string); return new Figure(jsonObject); } catch (JSONException ex) { throw new DecodeException("Error parsing JSON", ex.getMessage(), ex.fillInStackTrace()); }} And the encode method looks like: public String encode(Figure figure) throws EncodeException { return figure.getJson().toString();} FigureDecoderEncoder implements both decoder and encoder functionality but thats purely for convenience. But the recommended design pattern is to keep them in separate classes. In certain cases, you may even need only one of them. On the client-side, the Canvas is initialized as: var canvas = document.getElementById("myCanvas");var context = canvas.getContext("2d");canvas.addEventListener("click", defineImage, false); The defineImage method constructs the JSON structure as shown above and sends it to the endpoint using websocket.send(). An instant snapshot of the canvas is sent using binary transfer with WebSocket. The WebSocket is initialized as: var wsUri = "ws://localhost:8080/whiteboard/websocket";var websocket = new WebSocket(wsUri);websocket.binaryType = "arraybuffer"; The important part is to set the binaryType property of WebSocket to arraybuffer. This ensures that any binary transfers using WebSocket are done using ArrayBuffer as the default type seem to be blob. The actual binary data transfer is done using the following: var image = context.getImageData(0, 0, canvas.width, canvas.height);var buffer = new ArrayBuffer(image.data.length);var bytes = new Uint8Array(buffer);for (var i=0; i<bytes.length; i++) { bytes[i] = image.data[i];}websocket.send(bytes); This comprehensive sample shows the following features of JSR 356 API: Annotation-driven endpoints Send/receive text and binary payload in WebSocket Encoders/decoders for custom text payload In addition, it also shows how images can be captured and drawn using HTML5 Canvas in a JSP. How could this be turned in to an online game ? Imagine drawing a Tic-tac-toe board on the canvas with two players playing and others watching. Then you can build access rights and controls within the application itself. Instead of sending a snapshot of the canvas on demand, a new peer joining the game could be automatically transferred the current state as well. Do you want to build this game ? I built a similar game a few years ago. Do somebody want to rewrite the game using WebSocket APIs ? :-) Many thanks to Jitu and Akshay for helping through the WebSocket internals! Here are some references for you: JSR 356: Java API for WebSocket - Specification (Early Draft) and Implementation (already integrated in GlassFish 4 promoted builds) Subsequent blogs will discuss the following topics (not necessary in that order) ... Error handling Interface-driven WebSocket endpoint Java client API Client and Server configuration Security Subprotocols Extensions Other topics from the API

    Read the article

  • [BST] Deletion procedure

    - by Metz
    Hi all. Consider the deletion procedure on a BST, when the node to delete has two children. Let's say i always replace it with the node holding the minimum key in its right subtree. The question is: is this procedure commutative? That is, deleting x and then y has the same result than deleting first y and then x? I think the answer is no, but i can't find a counterexample, nor figure out any valid reasoning. Thank you. EDIT: Maybe i've got to be clearer. Consider the transplant(node x, node y) procedure: it replace x with y (and its subtree). So, if i want to delete a node (say x) which has two children i replace it with the node holding the minimum key in its right subtree: y = minimum(x.right) transplant(y, y.right) // extracts the minimum (it doesn't have left child) y.right = x.right y.left = x.left transplant(x,y) The question was how to prove the procedure above is not commutative.

    Read the article

  • New binary analysis tool finds FOSS in device firmware

    <b>ars Technica:</b> "Software development company Loohuis Consulting and process management consultancy OpenDawn have released a new binary analysis tool that is designed to detect Linux and BusyBox in binary firmware. The program, which is freely available for download, is intended to aid open source license compliance efforts."

    Read the article

  • QotD: Maurizio Cimadamore on Project Lambda Binary Snapshots

    - by $utils.escapeXML($entry.author)
    I'm glad to announce that the first binary snapshots of the lambda repository are available at the following URL:http://jdk8.java.net/lambda/As you can imagine, as the implementation of the compiler/libraries is still under heavy development, there are still many rough corners that need to be polished. I'd like to thank you all for all the patience and the valuable feedback provided so far - please keep it coming!Maurizio Cimadamore announcing the Project Lambda binary snapshots on the lambda-dev OpenJDK mailing list.

    Read the article

  • How to perform a binary search on IList<T>?

    - by Daniel Brückner
    Simple question - given an IList<T> how do you perform a binary search without writing the method yourself and without copying the data to a type with build-in binary search support. My current status is the following. List<T>.BinarySearch() is not a member of IList<T> There is no equivalent of the ArrayList.Adapter() method for List<T> IList<T> does not inherit from IList, hence using ArrayList.Adapter() is not possible I tend to believe that is not possible with build-in methods, but I cannot believe that such a basic method is missing from the BCL/FCL. If it is not possible, who can give the shortest, fastest, smartest, or most beatiful binary search implementation for IList<T>? UPDATE We all know that a list must be sorted before using binary search, hence you can assume that it is. But I assume (but did not verify) it is the same problem with sort - how do you sort IList<T>? CONCLUSION There seems to be no build-in binary search for IList<T>. One can use First() and OrderBy() LINQ methods to search and sort, but it will likly have a performance hit. Implementing it yourself (as an extension method) seems the best you can do.

    Read the article

  • How to tell Subversion to display binary files using an external program?

    - by lamcro
    I have some code which, like java, is stored in a binary format, and I have the applications to display and modify this code setup in the Subversion's config file. But when I run svn diff for these file, Subversion prevents me =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream I can still view them, but only with the --force argument Since all the files in the repository are of this binary code, how can I permanently force subversion to open the files for diff or edit mode?

    Read the article

  • Transferring binary data through a SOAP webservice? C# / .NET

    - by Jason
    I have a webservice that returns the binary array of an object. Is there an easier way to transfer this with SOAP or does it need to be contained in XML? It's working, but I had to increase the send and receive buffer to a large value. How much is too much? Transferring binary in XML as an array seems really inefficient, but I can't see any way to add a binary attachment using .NET.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >