- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a normal map saved as a JP2. Using the UIC codecs and the CIPPImage class, I want to load in the JP2, then convert it to a DXT5, but with the source red channel placed in the destination alpha channel.
Here is my code:
CStdFileInput inStream;inStream.Open("test.jp2")PARAMS_JPEG2K params;ZeroMemory(¶ms, sizeof(PARAMS_JPEG2K));params.nthreads = 2;CIppImage image;ReadImageJPEG2000(inStream, params,image);CStdFileOutput outStream;ioutStream.Open("test.dds")CIppImage alphaImage;image.ToRGBA32(alphaImage);int dxt5Order[4] = { 3, 1, 2, 0 };alphaImage.SwapChannels(dxt5Order);PARAMS_DDS ddsParams;ZeroMemory(&ddsParams, sizeof(ddsParams));ddsParams.ac = 1;ddsParams.nthreads = 2;ddsParams.fmt = DDS_DXT5;SaveImageDDS(alphaImage, ddsParams, outStream);
The resulting image is a gray-scale texture and a blank alpha channel. I get the same result whether or not I call SwapChannels on alphaImage, which leads me to believe that SaveImageDDS isn't handling something properly with 4 channel textures, or toRGBA32 is bugged. That or I'm doing something wrong, which is more likely :)
Does anyone see something is wrong w/ my approach?
Thank you,
Eric
Eric
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eric,
I think you should specify ddsParams.ac = 0 (to not add Alpha channel, as you already converted image to 4-channels). You may also need to specify ddsParams.ycocg = 0 - to prevent convertion to YCoCg color space before encoding to DXT5 format.
Regards,
Vladimir
I think you should specify ddsParams.ac = 0 (to not add Alpha channel, as you already converted image to 4-channels). You may also need to specify ddsParams.ycocg = 0 - to prevent convertion to YCoCg color space before encoding to DXT5 format.
Regards,
Vladimir
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eric,
I think you should specify ddsParams.ac = 0 (to not add Alpha channel, as you already converted image to 4-channels). You may also need to specify ddsParams.ycocg = 0 - to prevent convertion to YCoCg color space before encoding to DXT5 format.
Regards,
Vladimir
I think you should specify ddsParams.ac = 0 (to not add Alpha channel, as you already converted image to 4-channels). You may also need to specify ddsParams.ycocg = 0 - to prevent convertion to YCoCg color space before encoding to DXT5 format.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Vladimir. I was confused as to what the .ac meant. Setting it to zero fixed the issue.
Eric

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page