Transforma endereço de memoria em dados de imagem como um arraybytes

6 respostas
JavaX_JavaX

Bom dia, preciso de uma ajuda , tenho buscado na internet porem ainda não consegui achar uma solução , estou trabalhando em um projeto de processamento de imagem , onde tenho uma camera e acesso os dados dessa camera via dll e uso o Jna para fazer isso porem a dll me retorna um endereço de memoria onde se encontra os dados dessa imagem preciso pegar esse endereço e transforma em uma imagem , porem não encontro nada que possa me ajudar a iniciar esse processo, ainda estou na fazer de descoberta tentativa e erro.

Obs: caso alguem tenha entendido o meu problema , e tenha alguma ideia de como eu possa fazer isso e puder postar ou se tiver material que possa me ajudar por favor mande para meu e-mail [email removido]

Att Javax

6 Respostas

E

Se não me engano, você já postou a respeito do seu problema.

O seu problema é um pouco difícil de resolver sem mais detalhes.

Diga:

a) Que marca e modelo é sua câmera (se é uma webcam, uma câmera de vídeo digital normal, etc.)
b) Que software você está usando para capturar os dados
c) Se você está disposto a escrever alguma coisa em C ou C++ (ou talvez tudo) se não houver suporte Java para sua câmera
d) Se há algum software que veio com a câmera que consiga pelo menos gerar uma imagem JPG ou PNG

e outras coisas que forem necessárias.

(Você deve ter percebido que seu problema é mais difícil de resolver que parecia).

JavaX_JavaX

entanglement:
Se não me engano, você já postou a respeito do seu problema.

O seu problema é um pouco difícil de resolver sem mais detalhes.

Diga:

a) Que marca e modelo é sua câmera (se é uma webcam, uma câmera de vídeo digital normal, etc.)
b) Que software você está usando para capturar os dados
c) Se você está disposto a escrever alguma coisa em C ou C++ (ou talvez tudo) se não houver suporte Java para sua câmera
d) Se há algum software que veio com a câmera que consiga pelo menos gerar uma imagem JPG ou PNG

e outras coisas que forem necessárias.

(Você deve ter percebido que seu problema é mais difícil de resolver que parecia).

Obrigado Pelo Retorno , bom respondendo suas perguntas

a) é uma câmera fotografica Marca Atik
b) software quem o fabricante disponibilizou se chama Artemis
c) caso não houver mesmo como codificar em java terei sim que optar por outra linguagem
d) sim o software citado acima consegue me trazer uma imagem em Bitmap , porem não posso utilizar esse software
visto que esse projeto faz parte de um produto final que me obriga a construir a imagem no meu propio projeto

segue a parte do codigo que faz acesso a dll da camera e me retorta o ponteiro variavel pimg ou seja o endereços da memoria a imagem na memoria

public void Snapshot() {
  ArtemisHandle hCam = ConexaoDll() ;
  ArtemisHSC driver =  carregarDrivers() ;
 
 int ExposureDuration = 100;                                                   // exposure time in milliseconds
  int nImgBuf = 0;                                                              // allocated size of buffer

  short[] pImgBuf = null;
  
  // Ensure we're connected
	if (hCam == null){
         JOptionPane.showMessageDialog(null, "Erro Camera não está conectando", "Atenção", JOptionPane.ERROR_MESSAGE, null);
	} else {
         JOptionPane.showMessageDialog(null, "Camera Conectada com Sucesso", "Confirmação", JOptionPane.INFORMATION_MESSAGE, null);
        }
	// Don't switch amplifier off for short exposures
        driver.ArtemisSetAmplifierSwitched(hCam, ExposureDuration > 2.5f);

	// Start the exposure
	driver.ArtemisStartExposure(hCam, ExposureDuration*0.001f);

        Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        
         System.out.println("Version: " + driver.ArtemisAPIVersion()); 

        
	// Wait until it's ready, or ESC is pressed.
	// A more polished app would not use this method!
	
        while(!driver.ArtemisImageReady(hCam)){

         // 27 Cogigo Tecla Esc
         if (KeyEvent.KEY_PRESSED == 27){
          System.out.println("Saiu do while");
           driver.ArtemisAbortExposure(hCam);
           break;
	 }
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Logger.getLogger(FuncoesCamera.class.getName()).log(Level.SEVERE, null, ex);
        }
	}

	// We'll keep a local copy of the image so we can refresh the display even if
	// the original copy is lost.

        
        // Get dimensions of image
	IntByReference xRef = new IntByReference(); 
        IntByReference yRef = new IntByReference();
        IntByReference widRef = new IntByReference();
        IntByReference hgtRef = new IntByReference();
        IntByReference binxRef = new IntByReference();
        IntByReference binyRef = new IntByReference();
	// Get dimensions of image
	int x,y,wid = 0,hgt = 0,binx,biny;
	
        driver.ArtemisGetImageData(hCam, xRef, yRef, widRef, hgtRef, binxRef, binyRef);

        x = xRef.getValue();
        y = yRef.getValue();
        wid = widRef.getValue();
        hgt = hgtRef.getValue();
        binx = binxRef.getValue();
        biny = binyRef.getValue();
        
        //Variavel pimg abaixo Ponteito ou endereco de memoria da imagem
        Pointer pimg = driver.ArtemisImageBuffer(hCam);                          
        System.out.println("Conteudo do Variavel pimg "+pimg); // Conteudo do Variavel pimg native@0x66d0020
        
	if (pimg != null){
          // make sure we have enough space to store the image
            int imgsize = wid*hgt;

              if (nImgBuf < imgsize){
                 //delete[] pImgBuf;                                              //delete em C++ Serve Para Fazer Limpeza de Memoria no java Não e necessario visto que ele ja faz a limpeza
		 nImgBuf = imgsize;
                 pImgBuf = new short[nImgBuf];
               }

               pImgBuf = new short[pimg.getByte(imgsize*2)];                      // Equivalente ao memcpy C++
               //System.out.println(pImgBuf.hashCode());
               //memcpy(pImgBuf, pimg, imgsize*2);                       
                imgW=wid;
		imgH=hgt;
		//InvalidateRect(hWnd, NULL, FALSE);
                User32.INSTANCE.InvalidateRect(hWnd, null, false);
        }
        Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
 }

Att Javax

E

Você tem um exemplo em C ou C++ que usa essa mesma DLL (e que tenha sido disponibilizado pelo fabricante?) Não sei ler código JNA - acho sempre que tem alguma coisa errada.

Existe essa documentação (em forma de PDF) fácil de ser baixada em algum lugar? (De preferência no site do fabricante - se você simplesmente copiar para um site de compartilhamento de arquivos, já adianto que a maior parte dos proxies corporativos, incluindo o que uso, não deixa baixar nada desses lugares).

JavaX_JavaX

entanglement:
Você tem um exemplo em C ou C++ que usa essa mesma DLL (e que tenha sido disponibilizado pelo fabricante?) Não sei ler código JNA - acho sempre que tem alguma coisa errada.

Existe essa documentação (em forma de PDF) fácil de ser baixada em algum lugar? (De preferência no site do fabricante - se você simplesmente copiar para um site de compartilhamento de arquivos, já adianto que a maior parte dos proxies corporativos, incluindo o que uso, não deixa baixar nada desses lugares).

conforme sua solicitação segue exemplo em c++ que utiliza a mesma dll

// Snapshot.cpp
//
// This is a sample application which connects to an Artemis camera
// and takes a snapshot, which is then displayed on the screen.
//
// The code is intended to show how the Artemis SDK can be used.
// It is provided 'as is', and can not be guaranteed to be correct
// or suitable for any particular purpose other than as stated above.
//
// You are free to modify this code and include it in your own applications.
//

#include "stdafx.h"
#include <stdio.h>
#include "resource.h"

#include "..\..\ArtemisHSCAPI.h"

#define MAX_LOADSTRING 100

#define ARTEMISDLLNAME "ArtemisHSC.dll"


// Global Variables:
HINSTANCE hInst;								// current instance
HWND hWnd;										// current window handle
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];			// The title bar text

ArtemisHandle hCam=NULL;

int ExposureDuration=100; // exposure time in milliseconds
int BlackLevel=0;
int WhiteLevel=20000;

unsigned short* pImgBuf=NULL; // image buffer
int nImgBuf=0; // allocated size of buffer
int imgW=0; // width of image
int imgH=0; // height of image

// Foward declarations of functions included in this code module:
ATOM				MyRegisterClass(HINSTANCE hInstance);
BOOL				InitInstance(HINSTANCE, int);
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK	About(HWND, UINT, WPARAM, LPARAM);

void Connect();
void Disconnect();
void Exposure();
void Snapshot();
void DisplayImage(HDC hdc);
bool SaveBitmap(char *szFile);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_SNAPSHOT, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow)) 
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SNAPSHOT);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage is only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon(hInstance, (LPCTSTR)IDI_SNAPSHOT);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName	= (LPCSTR)IDC_SNAPSHOT;
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

	return RegisterClassEx(&wcex);
}

//
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   	// Load the Artemis DLL
	// This must be done before calling any of the other Artemis API functions.
	if (!ArtemisLoadDLL(ARTEMISDLLNAME))
	{
		MessageBox(hWnd, "Cannot load " ARTEMISDLLNAME, "Artemis", MB_OK);
		return FALSE;
	}

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWND, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szHello[MAX_LOADSTRING];
	LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

	hWnd=hWND;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				   break;
				case IDM_EXIT:
				   DestroyWindow(hWnd);
				   break;
				case IDM_FILE_SAVE:
					SaveBitmap(".\\Snapshot.bmp");
					break;
				case IDM_CAMERA_CONNECT:
					Connect();
					break;
				case IDM_CAMERA_DISCONNECT:
					Disconnect();
					break;
				case IDM_CAMERA_EXPOSURE:
					Exposure();
					break;
				case IDM_CAMERA_SNAPSHOT:
					Snapshot();
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			DisplayImage(hdc);
			EndPaint(hWnd, &ps);
			break;
		case WM_DESTROY:
			// Unload the Artemis DLL
			ArtemisUnLoadDLL();
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

// Message handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
				return TRUE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
}


// Message handler for Exposure dialog.
LRESULT CALLBACK ExposureDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
			SetDlgItemInt(hDlg, IDC_EXPOSURE, ExposureDuration, FALSE);
			SetDlgItemInt(hDlg, IDC_BLACK, BlackLevel, FALSE);
			SetDlgItemInt(hDlg, IDC_WHITE, WhiteLevel, FALSE);
			return TRUE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				if (LOWORD(wParam) == IDOK)
				{
					BOOL bOK=FALSE;
					int v;
					v=GetDlgItemInt(hDlg, IDC_EXPOSURE, &bOK, FALSE);
					if (bOK) ExposureDuration=v;
					v=GetDlgItemInt(hDlg, IDC_BLACK, &bOK, FALSE);
					if (bOK) BlackLevel=v;
					v=GetDlgItemInt(hDlg, IDC_WHITE, &bOK, FALSE);
					if (bOK) WhiteLevel=v;
				}
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
}


////////////////////////////////////////////
// Connect to first available Artemis device

void Connect()
{
	// Check if we're already connected
	if (hCam!=NULL)
	{
		MessageBox(hWnd, "Already connected!", "Artemis", MB_OK);
		return;
	}

	// Now connect to the first available camera
	hCam=ArtemisConnect(-1);
	if (hCam==NULL)
	{
		MessageBox(hWnd, "No camera available", "Artemis", MB_OK);
		return;
	}
}


////////////////////////////////////////////
// Disconnect from Artemis device

void Disconnect()
{
	// Only disconnect if we're currently connected!
	if (hCam!=NULL)
	{
		ArtemisDisconnect(hCam);
		hCam=NULL;
	}
}


////////////////////////////////////////////
// Set exposure parameters

void Exposure()
{
	DialogBox(hInst, (LPCTSTR)IDD_EXPOSURE, hWnd, (DLGPROC)ExposureDlg);
	// update display in case black/white levels changed
	InvalidateRect(hWnd, NULL, FALSE);
}


////////////////////////////////////////////
// Take a snapshot

void Snapshot()
{

	
	
	// Ensure we're connected
	if (hCam==NULL)
	{
		MessageBox(hWnd, "You must connect to the camera first.", "Artemis", MB_OK);
		return;
	}

	// Don't switch amplifier off for short exposures
	ArtemisSetAmplifierSwitched(hCam, ExposureDuration>2.5f);

	// Start the exposure
	ArtemisStartExposure(hCam, ExposureDuration*0.001f);

	SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));

	// Wait until it's ready, or ESC is pressed.
	// A more polished app would not use this method!
	while(!ArtemisImageReady(hCam))
	{
		if (GetAsyncKeyState(VK_ESCAPE)&0x8000)
		{
			ArtemisAbortExposure(hCam);
			return;
		}
		Sleep(100);
	}

	// We'll keep a local copy of the image so we can refresh the display even if
	// the original copy is lost.

	// Get dimensions of image
	int x,y,wid,hgt,binx,biny;
	ArtemisGetImageData(hCam, &x, &y, &wid, &hgt, &binx, &biny);

	unsigned short* pimg=(unsigned short*)ArtemisImageBuffer(hCam);

	if (pimg)
	{
		// make sure we have enough space to store the image
		
		int imgsize=wid*hgt;
		if (nImgBuf<imgsize)
		{
			delete[] pImgBuf;
			nImgBuf=imgsize;
			pImgBuf=new unsigned short[nImgBuf];
		}

		memcpy(pImgBuf, pimg, imgsize*2); 
		imgW=wid;
		imgH=hgt;

		InvalidateRect(hWnd, NULL, FALSE);
	}
	
	SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));

}



////////////////////////////////////////////
// If we have an image available, show it

void DisplayImage(HDC hdc)
{

	static BITMAPINFO  BmiMain; // data for bitmap used for refreshing display
	static HBITMAP hBmpMain=NULL;
	static int BufMainW;
	static int BufMainH;
	static int BufMainPitch;
	static unsigned char *pBufMain=NULL;

	RECT rt;
	static RECT rectBuf={0,0,0,0};
	GetClientRect(hWnd, &rt);

	if (memcmp(&rt,&rectBuf,sizeof(RECT))!=0 || hBmpMain==NULL)
	{
		// window has changed size. Dispose of old bitmap and make a new one
		
		if (hBmpMain!=NULL)
			DeleteObject(hBmpMain);
		hBmpMain=NULL;

		rectBuf = rt;
		BufMainW=rt.right-rt.left;
		BufMainH=rt.bottom-rt.top;
		BufMainPitch=(BufMainW*3+3)&~3;

		BmiMain.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
		BmiMain.bmiHeader.biWidth=BufMainW;
		BmiMain.bmiHeader.biHeight=-BufMainH;
		BmiMain.bmiHeader.biPlanes=1;
		BmiMain.bmiHeader.biBitCount=24;
		BmiMain.bmiHeader.biCompression=BI_RGB;
		BmiMain.bmiHeader.biSizeImage=BufMainH*BufMainPitch;
		BmiMain.bmiHeader.biXPelsPerMeter=0;
		BmiMain.bmiHeader.biYPelsPerMeter=0;
		BmiMain.bmiHeader.biClrUsed=0;
		BmiMain.bmiHeader.biClrImportant=0;
		hBmpMain=CreateDIBSection(hdc, &BmiMain, DIB_RGB_COLORS, (void **)&pBufMain, NULL, 0);

	}

	// First clear the buffer
	memset(pBufMain, 0, BufMainH*BufMainPitch);

	// clip to screen buffer
	int w=imgW;
	int h=imgH;
	if (w>BufMainW)
		w=BufMainW;
	if (h>BufMainH)
		h=BufMainH;

	int offset=BlackLevel;
	float scale=0.0f;
	if (WhiteLevel!=BlackLevel)
		scale=255.0f/(WhiteLevel-BlackLevel);

	for (int y=0; y<h; y++)
	{
		unsigned short *pSrc=pImgBuf+(y*imgW);
		unsigned char *pDst=pBufMain+(y*BufMainPitch);
		for (int x=0; x<w; x++)
		{
			// single input channel (greyscale)
			int v=*pSrc++;

			// adjust according to black/white levels
			v=(int)((v-offset)*scale);
			if (v<0) v=0;
			else if (v>255) v=255;

			// three output channels (B,G,R)
			*pDst++=v;
			*pDst++=v;
			*pDst++=v;
		}
	}

	HDC hDIB;
	hDIB=CreateCompatibleDC(hdc);
	HBITMAP hbmpOld=(HBITMAP)SelectObject(hDIB,hBmpMain);

	BitBlt(hdc, 0,0,BufMainW,BufMainH, hDIB, 0, 0, SRCCOPY);

	SelectObject(hDIB, hbmpOld);

}

////////////////////////////////////////////////////
// Save currently displayed image as a BMP file.
// This is for info only - BMP is not the ideal format
// for storing images taken using a 16-bit camera!
bool SaveBitmap(char *szFile)
{
	BITMAPFILEHEADER hdr;
	BITMAPINFOHEADER bmi;

	if (!pImgBuf)
		return FALSE;

	FILE *file = fopen(szFile, "wb");
	if (file==NULL)
		return FALSE;

	int imgPitch=((3*imgW)+3)&~3; // round up to multiple of 4

	bmi.biSize=sizeof(BITMAPINFOHEADER);
	bmi.biWidth=imgW;
	bmi.biHeight=imgH;
	bmi.biPlanes=1;
	bmi.biBitCount=24;
	bmi.biCompression=BI_RGB;
	bmi.biSizeImage=imgPitch*imgH;
	bmi.biXPelsPerMeter=0;
	bmi.biYPelsPerMeter=0;
	bmi.biClrUsed=0;
	bmi.biClrImportant=0;

	// Fill in the fields of the file header 
	hdr.bfType		= ((WORD) ('M' << 8) | 'B');	// is always "BM"
	hdr.bfSize		= bmi.biSize + bmi.biSizeImage + sizeof( hdr );
	hdr.bfReserved1 	= 0;
	hdr.bfReserved2 	= 0;
	hdr.bfOffBits		= (DWORD) (sizeof(hdr) + bmi.biSize);

	// Write the file header 
	fwrite(&hdr, sizeof(hdr), 1, file);

	// Write the DIB header
	fwrite(&bmi, bmi.biSize, 1, file);

	// Write image data
	int offset=BlackLevel;
	float scale=0.0f;
	if (WhiteLevel!=BlackLevel)
		scale=255.0f/(WhiteLevel-BlackLevel);
	char *pix = (char*)malloc(imgPitch);

	for (int y=0; y<imgH; y++)
	{
		unsigned short *pSrc=pImgBuf+((imgH-y-1)*imgW);
		char *pDest=pix;
		for (int x=0; x<imgW; x++)
		{
			// single input channel (greyscale)
			int v=*pSrc++;

			// adjust according to black/white levels
			v=(int)((v-offset)*scale);
			if (v<0) v=0;
			else if (v>255) v=255;

			// three output channels (B,G,R)
			*pDest++=v;
			*pDest++=v;
			*pDest++=v;
		}
		// pad to multiple of 4 bytes
		int x = 0;
		for (x*=3; x<imgPitch; x++)
			*pDest++=0;
		fwrite(pix, imgPitch, 1, file);
	}

	fclose(file);

	free(pix);
	return TRUE;
}

Att JavaX

E

Agora sim, estou entendendo melhor. (O meu problema com JNA é que várias coisas, como HWNDs e HINSTANCEs, são mapeadas para a mesma coisa (é porque são typedefs para a mesma coisa em C).

Basicamente, o formato que os bytes estão é apropriado para ser mostrado em um DIB (Device-Independent Bitmap). (A rotina “DisplayImage” é que é a essencial para eu entender como é que se deve processar a imagem.

Meu conselho: não deve ser tão difícil você, olhando a documentação da Microsoft ( http://msdn.microsoft.com ) , entender este trecho de código:

BmiMain.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);  
        BmiMain.bmiHeader.biWidth=BufMainW;  
        BmiMain.bmiHeader.biHeight=-BufMainH;  
        BmiMain.bmiHeader.biPlanes=1;  
        BmiMain.bmiHeader.biBitCount=24;  
        BmiMain.bmiHeader.biCompression=BI_RGB;  
        BmiMain.bmiHeader.biSizeImage=BufMainH*BufMainPitch;  
        BmiMain.bmiHeader.biXPelsPerMeter=0;  
        BmiMain.bmiHeader.biYPelsPerMeter=0;  
        BmiMain.bmiHeader.biClrUsed=0;  
        BmiMain.bmiHeader.biClrImportant=0;

e ver quais são as opções do Java (TYPE_3BYTE_BGR? sei lá qual) que são necessárias para usar aquele método da classe WritableRaster, http://docs.oracle.com/javase/6/docs/api/java/awt/image/WritableRaster.html#setSamples(int,%20int,%20int,%20int,%20int,%20int[]) .

Acho até que alguém já deve ter feito isso, é questão de você procurar …

JavaX_JavaX

entanglement,

Grato pela dica , estarei verificando

caso tenha mais alguma coisa ,

por favor poste ou mande no meu e-mail

estou na fase de levantar todo o tipo de

informação que eu conseguir Referente a processamento de imagem

vou verificar se na sua dica explica se e possivel transforma o endereco

de memoria em imagem no java

Grato Att JavaX

Criado 5 de junho de 2013
Ultima resposta 5 de jun. de 2013
Respostas 6
Participantes 2