Click here to Skip to main content
15,903,012 members

Comments by April2004 (Top 20 by date)

April2004 10-Oct-12 12:12pm View    
Deleted
#include <stdio.h>
#include <conio.h>
#include <string.h>

void outputshort(int i);
void outputint64(int i);

short mem[100];

void main(){
FILE* fp = 0;

short x[100];

char *filename = "C:\\chk\\test.dat";
fp = fopen(filename, "wb");
if (fp) {
for (int j = 0; j < 10; j++){
x[j] = (short)j;
fwrite(&x[j], 1, sizeof(x[j]), fp);
}
__int64 val = 9151314442816847742;
fwrite(&val, 1, sizeof(val), fp);
for (int j = 10; j < 20; j++){
x[j] = (short)j;
fwrite(&x[j], 1, sizeof(x[j]), fp);
}
__int64 val1 = 9114441220867751806;
fwrite(&val1, 1, sizeof(val1), fp);
}

fclose(fp);

FILE* fr = fopen(filename, "r");
if (fr) {
fread(&mem, sizeof(mem), 1, fr);
}

outputshort(9);
outputint64(24);

_getch();
}

void outputshort(int i) {
printf("short value is : %d\n", mem[i]);
}

void outputint64(int i) {
__int64 app1 = (__int64)mem[i+3] << 48;
__int64 app2 = (__int64)mem[i+2] << 32;
__int64 app3 = (__int64)mem[i+1] << 16;
__int64 app4 = (__int64)mem[i];
__int64 app = (__int64)app1 | (__int64)app2 | (__int64)app3 | (__int64)app4;
printf("int64 value is : %I64x", app);
}
April2004 10-Oct-12 12:11pm View    
Hi,
Here is my simple source code. I just cut out the points of my current problem.Thanks for your help.

#include <stdio.h>
#include <conio.h>
#include <string.h>

void outputshort(int i);
void outputint64(int i);

short mem[100];

void main(){
FILE* fp = 0;

short x[100];

char *filename = "C:\\chk\\test.dat";
fp = fopen(filename, "wb");
if (fp) {
for (int j = 0; j < 10; j++){
x[j] = (short)j;
fwrite(&x[j], 1, sizeof(x[j]), fp);
}
__int64 val = 9151314442816847742; //7E FF FF FF FF FF FF 7E
fwrite(&val, 1, sizeof(val), fp);
for (int j = 10; j < 20; j++){
x[j] = (short)j;
fwrite(&x[j], 1, sizeof(x[j]), fp);
}
__int64 val1 = 9114441220867751806; //7E 7C FF FF FF FF FF 7E
fwrite(&val1, 1, sizeof(val1), fp);
}

fclose(fp);

FILE* fr = fopen(filename, "r");
if (fr) {
fread(&mem, sizeof(mem), 1, fr);
}

outputshort(9);
outputint64(10);

_getch();
}

void outputshort(int i) {
printf("short value is : %d\n", mem[i]);
}

void outputint64(int i) {
__int64 app1 = (__int64)mem[i+3] << 48;
__int64 app2 = (__int64)mem[i+2] << 32;
__int64 app3 = (__int64)mem[i+1] << 16;
__int64 app4 = (__int64)mem[i];
__int64 app = (__int64)app1 | (__int64)app2 | (__int64)app3 | (__int64)app4;
printf("int64 value is : %I64x", app);
}

Best Regards
April2004 19-May-12 14:11pm View    
Hello,

Thank you very much for helping me several times. I found that above code is very effective for me. Now, I have additional desires on it.

In above code - Within one function, load the bitmap and set pixel on it.
My additional desires - In one function (for example: OnInitDialog), I load the bitmap. Set the pixel in another function (for example : ShowPixel). When the timer arrive specified time (for example : 1 minute), the based bitmap is stand still as it is loaded. And I just want to redraw ShowPixel with another different pixel color. Based on your code, I tried several times to get my requirements. But until now, I can't get solution yet. If possible, could you please guide me on it? Thanks again.
April2004 17-May-12 10:27am View    
Thank you very much for your advice.
Actually, I would like to fill various color in Rectangle. I need to set color, brush in for loop. My desire based on your concept is such as:

for (int i = 0; i < bmpInfo.bmHeight; i++) {
for(int j = 0; j < bmpInfo.bmWidth; j++) {
Gdiplus::SolidBrush brush(Gdiplus::Color(128, rand()%100, rand()%20, rand()%100));
g.FillRectangle(&brush, j, i, 1, 1);
}
}
With above code, I found that it is very slow to fill rectangle.
Could you please guide me any solution for speedy ?
And when the timer is arrive to target time(eg. 10 minutes), I would like to refill the rectangle with another various color. If I didn't clear the previous color, the correct color can't be displayed in next time. So, could you please guide me for the fastest way to clear Rectangle ?
April2004 14-May-12 12:35pm View    
I copied your code and run it. I can see the output is what I want. Thank you very much. Now, I am trying to understand your code.