Your right anduril462 was the ncols of 8 totally forgotten. CommonTater I didn't used the computer to calculate it, I just viewed the memory adresses of my computer to see if the compiler was doing...
Type: Posts; User: lamko
Your right anduril462 was the ncols of 8 totally forgotten. CommonTater I didn't used the computer to calculate it, I just viewed the memory adresses of my computer to see if the compiler was doing...
With this code : rptr[k] = aptr + (k * ncols); I'll get these values :
rptr adres = 0x602090 the value there stored is aptr[0] adres = 0x602010
the other pointers are aptr[1]0x602028,...
Thx for the info quzah, the padding problem for writing to file I used : __attribute__((__packed__))
edit :
Jup, foo[1][2]
Fine, that I'll understand, but now I want to find the specific struc[1][2] in memory. Any tips on that ?
I'll get It know why I don't have to use sizeof(BYTE) *image[0] is giving me the size of the struct.
But what is this line doing : rptr[k] = aptr + k*ncols; I thought it wat creating positions to...
I know that but I want to verify it's really working!
rptr[k] = aptr + (k * sizeof(BYTE) * 3 * ncols);
Where is the space it's using to save the struct ? Or how do I debug this to find it ?
I wanted another try but now array's contents to be contiguous in memory. I'm surelly gone follow all your advice but this is pure me messing around with pointers.
It's a two dimensional array Where do you guys think the structure gets saved in memory after seen te ptr values ?
Here's my code :
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t BYTE;
typedef uint32_t DWORD;
But why the 3 ? Who can explain to me that ! I need to allign in memory to write it back to file.
I want to create a distance of 1 byte between the pointers. So I don't get this debugging session where I'll get a distance of 3. Here's a image :
http://i54.tinypic.com/2j0zby0.png
Hopefully...
Finally a working version after also reading this : Pointers Usage in C++: Beginners to Advanced - CodeProject
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t ...
I've thought I was stuck but i've found this website : A Tutorial on Pointers and Arrays in C and it is explaining just the things I need to grasp all this stuff. Now of to master it :)
I've changed your code a bit to my vars
RGBTRIPLE **image = malloc(biHeight * sizeof(*image));
for (i = 0; i < biHeight; i++)
image[0] = malloc(bi.biWidth * sizeof(*image[0]));...
So int * is the pointer array, So it's using a array that is created by them self. That also explains the int **array.
so the first call is there to make room for an array of pointers
But it is here a int right ! So you could leave the *
copy paste from the 1st example Question 6.16 I thought about what you suggested it makes that clear to me now. Didn't know you could use structures like that.
That I'm also doing : 24 bit and my struct is RGBTRIPLE
But I need to learn some stuff on pointers to pointers for me to get whats going on here :
int **array <- how to change this ?
(RGBTRIPLE...
You mean something like this :
int **array = malloc(biHeight * sizeof(RGBTRIPLE *)); <- why do you need here a RGBTRIPLE * ?
array[0] = malloc(biHeight * bi.biWidth * sizeof(RGBTRIPLE)); <-...
Thx, I think I just got overwhelmed with all the stuff, didn't understand al the pointer stuff and syntax of fread.
Bmp format is no problem, i'm at step 4. But now to understand all the stuff.
I need some guidance on how to resize a bmp image at run time. I thought I should use a 2 dimensional dynamic array.
What steps do I need to take to do something like this. fread and fwrite are...
You're right, I didn't post that code because I'm sure that there wasnt a problem. All the things you mentioned are all there.
Thx for the quick reply, that wiki page I have also used a lot and is...
I'm a shamed, because I had lots of errors and didnt know when to use -> or when to use . So I just was using some trial and error. But It seem it had nothing to do with that :)
People,
I have a little problem and I don't seem to get. I've seen examples that worked this way but mine won't.
typedef struct
{
BYTE rgbtBlue;