Visual C++ :: Draw Image Using 2D Byte Array?

Feb 8, 2013

I like to Draw an Image Using two dimensional byte array[512][256].

I used SetPixelV method to plot the image.

But Its very slow & hidden some buttons(Controls) at run time in the same dialog.

For reference i send some code,

Code:
for(row = 0; row <512; row ++)
{
for(col = 0; col < 256; col++)
{
Data[row][col] = y;
SetPixelV(d, 10+row, 10+col, RGB(Data[row][col],Data[row][col],Data[row][col]));
}
}

View 14 Replies


ADVERTISEMENT

Visual C++ :: How To Convert PNG Image Into Byte Array

Mar 12, 2013

I m loading a png image by using the ATLImage library.

CImage Image;
Image.Load (L"D:ImagesPNG_ImagesImage7.png");

how to retrieve the byte array value of this png image. I tried retrieving it as

byte *png = reinterpret_cast<BYTE *>(Image.GetBits());

but when i access the data , der is a loss of data while converting it in the above manner.

I found a snippet in net for decoding the raw data . but der is a line is the code which is unknown to me. The code is as follows :

CImage atlImage;
HMODULE hMod = GetModuleHandle(NULL);
atlImage.Load(bstr);
void* pPixel = atlImage.GetBits();
intpitch = atlImage.GetPitch();
intdepth = atlImage.GetBPP();

[Code] ....

How do I get the byte * value form the png image loaded?

View 3 Replies View Related

C++ :: OpenGL - Draw On Top Of Image

Jun 22, 2014

This is my first time using opengl and I am experimenting with adding/drawing polygons/points/etc. on top of a PPM image. The image is already loaded when the application runs. My attempt to draw a square is from lines 30 - 35. The program runs but the square is not present. Just the image.

#include<windows.h>
#include <stdio.h>
#include <stdlib.h>
#include<Gl/gl.h>
#include<GL/glut.h>

int n;
int m;
int *image;

[Code] ....

View 5 Replies View Related

Visual C++ :: How To Draw 2D Array Of Data In MFC

Jun 3, 2013

I have a circle of data that is represented as:

vector<vector <unsigned char> >* data;

The first dimension of this vector is the angle of the data so there are 360 angles, and the second dimension is the bins of the data in which there are 512 bins per angle. Each bin has a value from 0 to 15 to determine the intensity of the bin. So basically, when this is all display, there will be a circle of data, with varying colors of intensity at each bin.

What is the best approach to doing this in MFC? How to draw this on the screen?

View 12 Replies View Related

Visual C++ :: Processing Time For PVOID Into Byte Array Conversion

Mar 12, 2013

In my project I'm using PVOID pointer to store real time data. After getting this data I will convert the data into byte array, like below

Code:
byte *bPoint = NULL;
PVOID pvData;
byte TempArr[1024];
bPoint = (byte*) pvData;
for(int i=0;i<1024;i++)
TempArr[i] = (byte) (*bPoint + i);

Processing time for the above code takes 9500 to 9900 microseconds (Used QueryPerformanceCounter).

Code:
TempArr[0] = ((BYTE*) pvData) [0];

This code takes 1100 to 1200 microseconds. My doubt is, The processing time of PVOID data into byte array conversion takes time like above? Or any other easy way(PVOID data into byte array conversion) to reduce the processing time?

View 14 Replies View Related

Visual C++ :: Using 2D Array - Displaying Bitmap Image With Scrolling

Mar 11, 2014

My requirement is,

Read *.bmp image and displaying bitmap image with scrollbar in a MFC dialog application.

I was done using this

I was read the *.bmp image as a pixel data and stored by 2D Array,

Now i want to Display this 2D array as bitmap image with scrollbar separately in the same dialog. How can i display bitmap with scrollbar using 2D array?

View 10 Replies View Related

C# :: Compare The Image Of A Button To Another Image In Visual Studio

Jul 3, 2014

Im trying to compare the image of a button to another image in Visual Studio like so...

//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");

[Code]...

btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))

I do have a feeling ive done something wrong here (Yes im a noob /> )

Variable active, is the same image as the buttons default (Well should be)

View 1 Replies View Related

Visual C++ :: Draw Buffer With Raw Data?

Nov 19, 2012

Got buffer with raw data. How to display it in MFC dialog and refresh it?

View 3 Replies View Related

Visual C++ :: Draw Grid Over Bitmap In Scrollview

Jul 5, 2013

I have a CScrollView that displays a bitmap and I'm trying to draw a grid that I can turn off and on by check box and when the mouse is over a section of the grid that square highlights... I do all the drawing in the ondraw function... But when I have many grid squares it becomes slow to scroll and to highlight the square the mouse is over... I'm not sure the best way to go about this and where to place code to speed it up... The bitmap is only loaded once... But in ondraw the grid has to redraw every time scrolled and when mouse moved over a square.. In onmousemove I call invalidate so the square under mouse changes...

View 5 Replies View Related

Visual C++ :: Fstream Adds Extra Byte?

Feb 7, 2014

I've been having this odd problem when I write a file byte by byte, when I write a byte (dec)10 it adds a (dec)13 in front of it, and as far as I can tell, this is the only byte value that does this.

and most annoyingly, I can't read that (dec)13 with fstream, the only reason I know it's adds it, is because I used an external hex editor.

here is the code that causes the problem:

Code:
#include <fstream>
using namespace std;
int main()
{

[Code]...

but the output file reads '0D 0A' (that's in hex, '13 10' in decimal) when viewed in a hex editor. no other number (that I've tried) adds that extra 13.

View 2 Replies View Related

Visual C++ :: Draw Multiple Lines And Move Them On Screen

Jul 28, 2013

I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.

View 4 Replies View Related

Visual C++ :: How To Draw Pixel-level Color Gradients In CScrollView

Oct 6, 2012

i wish to plot a mathematical function on a 2-dimensional grid. The function will be represented by 3 sets of floats, x-values, y-values, and z-values. Obviously, it is impossible to plot 3 such data sets on a 2D grid, so one approach is to use pixel coloration to represent the z-values.

Those examples (and there are many to be found) show something like the function of the complex variable z, f(z) = exp(z). I have attached a exp(z).jpg example of the imaginary part of the plot exp(z).

My question is: How to accomplish such a gradient colorization, assuming one already has the data?

I have experimented with Gdiplus SetPixel, but I have not figured out how to produce a smooth gradient.

Here's my attempt to create a simple gradient:

Code:
CDC * pDC = GetDC();
Graphics graphics(pDC->m_hDC);
CRect r;
GetWindowRect(&r);
ScreenToClient(&r);

[Code] ....

View 1 Replies View Related

Visual C++ :: Draw A Shape Or Font On Dialog And Then Fill The Outline?

Jul 8, 2013

I am trying to draw a shape or font on dialog and then fill the outline. I have 2 buttons on this 2 buttons I have the following code

Code:
case IDC_BUTTON1:
MessageBox(hDlg, L"Start Drawing!!", L"ButtonPressed", MB_OK | MB_ICONEXCLAMATION);
hDC = GetDC(hDlg);
brush = CreateSolidBrush(RGB(128, 128, 128));
SelectObject(hDC, brush);

[code].....

When I remove the BeginPath() and EndPath() functions my lines are being drawn. But when I insert this BeginPath() and EndPath() and StrokeAndFillPath(hDC); the nothing is being drawn.

Why it is not doing as per the expectations. I want to draw a shape for example A with a outline. And i want it to be closed when drawing is ended and filled the hollow portion.

What am I doing wrong in this ?I am not implementing it in WM_PAINT but drawing is done in WM_LBUTTONUP.

View 6 Replies View Related

C# :: How To Draw More Than One Line In WPF Using Array

Jul 8, 2014

I used the following code. I called a method named lets_draw

private void lets_draw() {
int i,z;
z = 40;
Line[] line = new Line[20];
for(i=1;i<=10;i++) {

[Code] ....

But it showed the following message

"An unhandled exception of type 'System.NullReferenceException' occurred in SkeletalTracking.exe
Additional information: Object reference not set to an instance of an object."

View 1 Replies View Related

C++ :: How To Draw Unoccupied Value From Array

Jan 5, 2015

Let's say there are three slots in my array (3 pieces of hardware to be used). If one worker comes in, it takes an instrument, and I tag it as used on random basis. Next, the next worker comes in, it takes another unused instrument randomly and so on. When the first worker finishes using that instrument, he returns it back to the inventory. How should I write such code in C++?

View 8 Replies View Related

Visual C++ :: Sending Packet Of Type Byte To Serial Port

Feb 26, 2013

I need to send a packet of type byte:

0x00, 0x01, 0x02, 0x11, 0x00, 0x00

to a device via the serial port and then I receive and store data coming from device like this:

0x01, 0x01, 0x01 , 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00.

Writing lines of code through which:

1) I create the array
2) the sending the array to serial port
3) I'll see what I'm sending
4) I get the data

I'm using Visual Studio 2010 and C + + or VC++ language.

View 14 Replies View Related

C/C++ :: Separate Byte Of Array Into Nibble For New Array

Oct 1, 2012

How can I separate byte array and put nibbles in a new array?

when I try following:

byte in[]={0xab,0x11,0x22,0x33,0xbb}; 
byte out[10];  
void seperatebyte(byte* input, byte* output) {  
  for(int i = 0;i<sizeof(input);i++)  {   
        output[i*2]  = (input[i] >> 4) & 0xf;
        output[(i*2)+1]  = input[i] & 0xf;
     }  
}  

seperatebyte(in,out); //gives output of  

10 11 1 1 184 1 184 0 0 0

I expect 10 11 1 1 2 2 3 3 11 11

View 2 Replies View Related

C# :: Reading A File Into A Byte Array?

Jun 25, 2014

I basically want to create a save editor application that will enable people to alter various values in the save by clicking on releveant buttons and then also for the editor to auto update the checksum when changes are done.

The save file is in hex so from what I can gather I would need to create a button to open the file using 'open file dialogue' and then read the file into a byte array so that the values can be called at any time when a particular butto is pressed and the application will then seek to the point in the file to make the required changes.

View 3 Replies View Related

C# :: Get Posted File From Byte Array

Oct 7, 2014

I have an application that has its own embedded web server. I am trying to add jQuery/Ajax file upload capabilities to the application however, I am running into issues getting the posted file. The jQuery/Ajax portion is similar to this method here. Due to the way the webserver was written (its in a dll and I do not have access to the source), the posted file comes in as a byte[]. If I try to save the byte array directly to file using:

File.WriteAllBytes("path", ByteArray)

I end up with a corrupt file that I cannot open. I believe this is because the byte array also contains the posted file header info (Content-Disposition, name, filename, etc.). If I view the contents of the byte array using:

System.Text.Encoding.Default.GetString(ByteArray)
the header info can be viewed as:
------WebKitFormBoundaryQfPjgEVpjoWgA5JL
Content-Disposition: form-data; name="0"; filename="someimage.png"
Content-Type: image/png
‰PNG

Based on the selected file size and the size of the byte array, the entire file is in the byte array. How can I go about extracting and saving the posted file from the byte array?

View 2 Replies View Related

C++ :: Byte Array To Double Conversion?

Dec 5, 2014

I'm trying to understand why a conversion from a byte array (unsigned char) to a double works when done one way and not antoher.

In the example code I test by hard coding an unsigned char array of the same bytes that the double consists of.

When I copy the bytes to a long long and cast to double the result is not the original double but if I use a struct the bytes can be set and the conversion happens.

Seems to me that both ways should work. I'd just like to know what is going on with the "struct way" that makes the conversion correct. I see in debugger that the bytes in memory are the same for piAsLong and u.bytes.

My compiler is VS 2012 and a long long and double are both 8 bytes (tested with sizeof). This is learning activity only.

Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
union {
double d;

[code]....

View 6 Replies View Related

C++ :: Convert 2-byte Array To Short Int?

Nov 18, 2012

I'm having trouble reading a block of bytes into a vector of short ints. My code is as follows:

Code:
FileStream.seekg(2821);
vector<short> g_Data;
int iter = 0;
g_Data.reserve(maxNumOfInts);

[Code] ....

The relevant block of data starts at offset 2821 in the file. Every two bytes are a signed short integer. What's odd is that it's giving me the correct results only part of the time. At offset 1052421 and 1052422 there are two bytes 40 and 1F that are correctly read in as 8000, but at offset 1052415 and 1052416 bytes 88 and 13 are read in as -120 instead of 5000.

I don't see anything wrong with my code, though, unless I'm misunderstanding completely how to convert an array of two bytes into a single float. Is my method correct? Better still, is there some way to just convert en mass an array of bytes into a vector of signed short ints?

View 5 Replies View Related

C++ :: Encoding Byte Array Data?

Apr 23, 2012

I'm trying to parse some binary data in the form of an array of bytes and I've come across something that is confusing me related to the representation of data as chars versus ints. It's a bit of a long story, but the byte array contains a mixture of character data and integer data which I' having trouble unravelling. The problem seems to arise from the issue below:

Code:
const char * ch_arr = "abcd";
const unsigned int * ui_arr = (const unsigned int*)ch_arr;
cout << ui_arr[0] << endl;
unsigned int ui = 'a';
ui = ui << 8;
ui |= 'b';
ui = ui << 8;
ui |= 'c';
ui = ui << 8;
ui |= 'd';
cout << ui << endl;

I expected both the output lines to be the same, since they contain the same bytes (I believe), but I get:

Code:
1684234849
1633837924

View 4 Replies View Related

C# :: Store Each Char Of A String Into Byte-array?

Apr 25, 2014

I am trying to store each char of a string(string a ="1100") into a byteArray ( byte[] byteArray = new byte[4]. its not showing any error but its storing like below:

byteArray[0] = 49
byteArray[1] = 49
byteArray[2] = 48
byteArray[3] = 48

and what i want is

byteArray[0] = 1
byteArray[1] = 1
byteArray[2] = 0
byteArray[3] = 0

I don't know why but its replacing 1 with 49 and 0 with 48.what am I doing wrong or how to do this?

my code is as below

byte[] byteArray = new byte[4];)/>
int binArrayAdd = 0;
string a ="1100";
foreach (char Character in a)
{
byteArray [binArrayAdd] = Convert.ToByte(Character);
binArrayAdd++;
}

View 4 Replies View Related

C Sharp :: Byte Array To Char Conversion

Jul 26, 2012

- API Function

TestSend(ref char data, ref int len, char slot);
---------------------------------------------------
 Byte[] IccSelect = new Byte[7]{
                              0x00,    
                              0xA4,    // INS 
                              0x04,    //1                              0x00,    //2                              0x0E,    
                              0x31,    
                              0x50,    
                              };  
Int32 len = 20;

TestSend(ref ??, ref len, '0');//byte array to char conversion

View 1 Replies View Related

C Sharp :: How To Extract A String From Byte Array

Feb 11, 2014

i need to search for a keyword in a binary(.raw)file and have to extract the characters(until a '&' character is found)that immediately following the keyword .

View 1 Replies View Related

C Sharp :: Write Byte Array To Textboxes?

Jan 22, 2015

In my application there is a structure that holds 200 parameters for 200 tests. These structure is converted to byte array . I want to write this byte array to a file in save button and when I click open button, this file must open and write these bytes to corresponding text boxes. How it possible.?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved