How to decode BC1 and change the color palette and encode it again

Hi all. I have loaded a dds file which is compressed using BC1 and I want to decode it and manipulate the pixels and color palette and encode it again. I believe it should possible using D3DXDecodeBC1 and D3DXEncodeBC1 in BH.cpp, but I don't know
how to use them after loading the dds file. I have problem with argument parameters like how to connect them to the loaded dds file. (I don't want to decompress the dds file)

Typically you would load the BC1 DDS file using LoadFromDDSFile, decompress to an RGB format using Decompress, manipulate the Image pixels, then compress using Compress, and then write the result using SaveToDDSFile.

If you want to manipulate the individually encoded blocks without decompressing the whole image, then you should just use LoadFromDDSFile and then walk the data yourself in the resulting Image. Look at the code in DirectXTexCompress.cpp for examples
of working with the Image data. It's pretty simple:

1) for example: temp[0]. then there are some m128_f32 and things like that which I am not familiar with those things.

2) for example as pointer: temp-> then I get the same stuff as in the first way

Please let me know for example, how I can change the color pixel of each pixel in the 4*4 block.

Another issue is that as I understand in the DXT1 (BC1) when a texture is compressed using DXT1 its pixels are segmented into 4*4 block of pixels and for each block a 4 color palette is calculated and after the compression all the RGB colors are converted
to those 4 colors only. The question is how can I access to those colors in a dds file after loading and change them or just print them out.

I mean, after compression each pixel in a block should only have one of those 4 colors from the palette which is represented by a number meaning there are only 4 numbers which each pixel in a block can take, I want to access those numbers.

I stored the bc->bitmap in an dynamically allocated array with the same type as bc->bitmap which uint32_t. I manipulated the array and now I want to save the dds file again. I need to change the bc->bitmap and then save the same dds file using another
name so in the end I would have the original file and the manipulated file. I tried to do as you said and tried to change the bc->bitmap but it says that the bc->bitmap is not modifiable. (I think because it is const).

And I removed all the consts from sptr and pSrc Now there is no more error but still when I save the file the changes in the bc->bitmap is not effective and the original image is saved instead of the new one.

when I change the bc->bitmap It should change the bitmap of the image for that particular pixel. correct me if I am wrong please.

<p>D3DX_BC1 *bc = reinterpret_cast&lt;D3DX_BC1 *&gt;( sptr );&nbsp; should work fine with the const' removed.</p> <p>I can't tell from your post what the code looks like for loading and saving the data, but you should probably
just walk through it in a debugger to see what's happening.</p>