About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Grayscale converting
Author Message
Harry Offline
Member

Post: #1
Grayscale converting
Is it possible to convert image in game to grayscale? Or should I convert all .gfx of mini map into bmp, then convert in eg PS to grayscale and again to gfx?
03-05-2010 05:30 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Grayscale converting
yes you can lock image, change pixels, unlock
there is tutorial for manually creating images
03-05-2010 06:21 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #3
RE: Grayscale converting
Ok. I make some changes in tutorial and now my image is convert to grayscale but only when I load gfx file without mipmaps and in A8R8G8B8 format. Is it possible to make convert with DXT5 files?

Code:
Color clr;
Flt color;

if(image.lock()) // in order to edit the texture we must first lock it
   {
      FREPD(y,image.y()) // iterate through all y's
      FREPD(x,image.x()) // iterate through all x's
      {
          clr=image.color(x,y);
          color=0.3*clr.r+0.5*clr.g+0.2*clr.b;
          image.color(x,y,Color(255,color,color,color)); // set image color at (x,y) coordinates
      }
      image.unlock(); // unlock
   }
(This post was last modified: 03-05-2010 07:24 PM by Harry.)
03-05-2010 07:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Grayscale converting
if you have source dxt image, you need to first convert it to a8r8g8b8 (Image::copy)
edit
to make mip maps work
you need to call updateMipMaps after unlock
03-05-2010 11:32 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #5
RE: Grayscale converting
Thanks. Does convert from dxt to a8r8g8b8 and again to dxt after operations make image with lower quality than the source image?
03-06-2010 11:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Grayscale converting
that depends on directx implementation, and if you modify the image a8r8g8b8
since your modifying the a8r8g8b8 to greyscale then the quality can get slightly worse
03-06-2010 01:47 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #7
RE: Grayscale converting
Ok I understand, thanks.
03-06-2010 03:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply