|
1
|
Programación / Java / ProcessBuilder- Ayuda para Ejecutar en terminal.
|
en: 26 Agosto 2016, 01:07 am
|
Alguien me podria decir como poner este codigo de forma correcta?ProcessBuilder processBuilder = new ProcessBuilder(sudo partclone.ntfs -c -s /dev/sda5 | gzip -c9 > /media/toni/Datos/toniARCH.bk)
Se que debe quedar algo asi "sudo", "partclone.ntfs", "-c", "-s", "/dev/sda5"
pero no lo consigo
|
|
|
3
|
Programación / Java / Ayuda con mi codigo. (Enviar buffer de imagen de c++ a java)(SOCKETS)
|
en: 18 Diciembre 2015, 16:59 pm
|
Estoy intentando hacer streaming capturando la pantalla del pc y enviando el buffer por socket a java(Android). Al parecer mi codigo funciona bien pero al poco de iniciar el streaming me da error en java(Android) Alguna idea?. Este es mi codigo de c++: byte* buffer=NULL; ULONG tamañobuffer=NULL; ULONG comprobacion = NULL; CapturarPantalla(buffer,tamañobuffer, 50);
long int NetInt;
NetInt = htonl((unsigned)tamañobuffer); send(s2, (char *)&NetInt, sizeof(long), 0);
recv(s2,(char*)&comprobacion,sizeof(long),0); long int hostint = ntohl(comprobacion); printf("\n%lu\n", hostint); send(s2, (char*)buffer,(int) tamañobuffer, 0);
Y mi codigo java es este : private Runnable updateTask = new Runnable () { public void run() { int tamaño=0; try { InStream = new DataInputStream(btSocket.getInputStream()); tamaño= InStream.readInt(); } catch (IOException e) { e.printStackTrace(); } try { outStream= new DataOutputStream(btSocket.getOutputStream()); outStream.writeInt(tamaño); } catch (IOException e) {
// TODO Bloque catch generado automáticamente
e.printStackTrace(); }
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize]; int totalBytesRead = 0;
int numBytesRead = 0;
byte[] result = new byte[tamaño]; while (totalBytesRead != tamaño ) { try { numBytesRead = InStream.read(buffer); } catch (IOException e) { // TODO Bloque catch generado automáticamente e.printStackTrace(); } System.arraycopy(buffer, 0, result, totalBytesRead, numBytesRead); totalBytesRead += numBytesRead; } Bitmap bmp = BitmapFactory.decodeByteArray(result, 0, tamaño); ImageView image = (ImageView) findViewById(R.id.imageView1); image.setImageBitmap(bmp); buffer = null; totalBytesRead = 0; numBytesRead = 0; result=null; mHandler.postDelayed(updateTask, 20);
} };
|
|
|
5
|
Programación / Java / Problema al recivir imagen c++/java
|
en: 21 Septiembre 2015, 16:00 pm
|
Buenas. Intento enviar imagen tras imagen en c++ y ir guardarlas en java(android). No se por que pero es como que guarda imagen tras imagen en el mismo archivo. Ayuda¡¡¡¡ //c++ unsigned char *mem; size_t mem_size; send(s2,(char*)mem,mem_size, 0);
Y lo recivo en java asi: //JAVA int u=0; @Override public void run() { try { while (!isInterrupted()) { @Override public void run() { File result = new File( "/sdcard/1/testImg"+u +".jpg" ); u++; try { byte[] buffer = new byte[ 4096 ]; int bytesRead; while ( (bytesRead = in.read( buffer )) != 0 ) { outt.write( buffer, 0, bytesRead ); } outt.flush(); outt.close(); out.append( "Done." ); e.printStackTrace(); e.printStackTrace(); } } }); } } } };
|
|
|
6
|
Programación / Java / Como cargar un jpg en un imageview desde un buffer ? (Android)
|
en: 3 Septiembre 2015, 18:50 pm
|
Intento ir actualizando el imageview con la llegada del buffer pero no carga la imagen. Este seria el codigo... Aver si me pueden ayudar. Envio de datos desde c++; unsigned char *mem; size_t mem_size;
send(socket,(char*)mem,mem_size, MSG_OOB);
thread que recibe los datos y los muestra en el imageview Thread t = new Thread() {
@Override public void run() { try { while (!isInterrupted()) { Thread.sleep(1000); runOnUiThread(new Runnable() { @Override public void run() { // update TextView here! int o=0; try { o = inStream.read(buffer,0,buffer.length); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ImageView img=(ImageView)findViewById(R.id.imageView1); Bitmap bit =BitmapFactory.decodeByteArray(buffer, 0, buffer.length); img.setImageBitmap(bit); img.invalidate(); } }); } } catch (InterruptedException e) { } } };
t.start();
|
|
|
7
|
Programación / Programación C/C++ / Sabriais decirme como reducir el tamaño de la imagen creada con directx?
|
en: 17 Julio 2015, 08:23 am
|
Este es el code que e ido generando y el cual me gustaria editar para reducir el tamaño del archivo final. // ConsoleApplication7.cpp: define el punto de entrada de la aplicación de consola. //
#include "stdafx.h"
#include <stdio.h> #include <Windows.h> #include <d3d9.h> #include <d3dx9.h> #include <D3dx9tex.h>
#include <iostream> #include <fstream> using namespace std;
#pragma comment( lib, "d3d9.lib" ) #pragma comment( lib, "d3dx9.lib" )
void main() { CoInitialize(NULL);
LPDIRECT3D9 d3d9; LPDIRECT3DDEVICE9 d3ddev; d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
int ww = GetSystemMetrics(SM_CXSCREEN); int wh = GetSystemMetrics(SM_CYSCREEN);
HWND hwnd = GetDesktopWindow(); D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.BackBufferCount = 3; d3dpp.BackBufferWidth = ww; d3dpp.BackBufferHeight = wh; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.MultiSampleQuality = 0; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.hDeviceWindow = hwnd; d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
IDirect3DSurface9* render; IDirect3DSurface9* dest;
int i = 0; while (i++ < 100){ d3ddev->CreateOffscreenPlainSurface(ww, wh, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &dest, NULL); d3ddev->GetFrontBufferData(0, dest);
LPD3DXBUFFER buffer; D3DXSaveSurfaceToFileInMemory(&buffer, D3DXIFF_JPG, dest, NULL, NULL); DWORD imSize = buffer->GetBufferSize(); void* imgBuffer = buffer->GetBufferPointer();
fstream out; /////////////////////// char file[100]; snprintf(file, 100, "toni%d.jpg", i); //////////////////// out.open(file, std::ios_base::binary | std::ios_base::out); out.write((char*)imgBuffer, imSize); out.clear(); out.close();
dest->Release(); }
d3ddev->Release(); d3d9->Release();
CoUninitialize(); }
|
|
|
8
|
Programación / ASM / asm en c++ (Devolver variable con return) ayuda.
|
en: 12 Enero 2015, 02:52 am
|
Hola, de entrada decirles que no se ni pajolera idea de asm... por eso mi pregunta. Como consigo hacer el return de la variable "primero" ? char lanzar(){ char primero = 0;
__asm{
call des des : pop primero
} return primero; }
|
|
|
9
|
Programación / Programación C/C++ / Por que me da error? ( declarar api y realizar llamada )
|
en: 20 Diciembre 2014, 19:49 pm
|
Por que me tira estos errores? error C2371: 'SHELLEXECUTEINFO' : nueva definición; tipos básicos distintos error C2371: 'LPSHELLEXECUTEINFO' : nueva definición; tipos básicos distintos error C2373: 'ShellExecuteExA' : nueva definición; modificadores de tipo distintos error C3861: 'ShellExecuteExA': no se encontró el identificador Este es el codigo #include "stdafx.h" #include <windows.h>
typedef struct _SHELLEXECUTEINFO { DWORD cbSize; ULONG fMask; HWND hwnd; LPCTSTR lpVerb; LPCTSTR lpFile; LPCTSTR lpParameters; LPCTSTR lpDirectory; int nShow; HINSTANCE hInstApp; LPVOID lpIDList; LPCTSTR lpClass; HKEY hkeyClass; DWORD dwHotKey; union { HANDLE hIcon; HANDLE hMonitor; } DUMMYUNIONNAME; HANDLE hProcess; } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
BOOL ShellExecuteEx( _Inout_ SHELLEXECUTEINFO *pExecInfo );
int _tmain(int argc, _TCHAR* argv[])
{
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = NULL; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = NULL; ShExecInfo.lpFile = "cmd.exe"; ShExecInfo.lpParameters = NULL; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_MAXIMIZE; ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
return 0; }
|
|
|
10
|
Programación / Programación C/C++ / Me podeis explicar este pequeño codigo?. " Llamar a function shellexecute "
|
en: 20 Diciembre 2014, 16:54 pm
|
Si me pudierais explicar y poner un ejemplo de como llamar a la funccion os lo agradeceria mucho.Archivo toni.h #include <windows.h>
typedef HINSTANCE (WINAPI *SHELLEXECUTE)( _In_opt_ HWND hwnd, _In_opt_ LPCTSTR lpOperation, _In_ LPCTSTR lpFile, _In_opt_ LPCTSTR lpParameters, _In_opt_ LPCTSTR lpDirectory, _In_ INT nShowCmd );
Archivo toni.cpp SHELLEXECUTE shellexecuteS = NULL;
shellexecuteS = (SHELLEXECUTE)(*((DWORD *)(dwAddr + 64)));//---> ESTA PARTE NO LA ENTIENDO
ShellExecuteS(NULL, NULL,(char*) "calc.exe", NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
|
|