1
Graphics / Image.LoadFromFile("sprite.tga") Won't load the im
« on: August 21, 2007, 02:10:10 am »
Did you make sure to put the DLL's in extlibs\bin in your PATH somewhere?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Using unions for this leads to undefined behaviors (according to the C++ standard). More practically, the result won't be the same whether you run it on a big-endian processor or a little-endian one.
The only way to get a portable behavior is to combine / extract the components using bitwise operators.
Pixels are not stored in a two-dimensional array, so I can't return a pointer to a sub-rectangle. To give access to a sub-part of the pixels array, I'd need to return a proxy class which would have to add offsets to match the new X and Y values.
int nStartY = 50, nStartX = 50, nWidth = 50, nHeight = 50;
for(int y = 0; y < nHeight; y++) {
unsigned int *pRow = image.GetPixelsPtr(nStartX, nStartY+y);
for(int x = 0; x < nWidth; x++) {
// Generate and set color based on x and y
pRow[x] = color;
}
}