   how to change png file?
  To a png file(four color channel), how  to change pixel's red,green and blue value to 100 respectively if its alpha value is smaller than 5. How to realize it? Any clue is appreciated.   
  (FYI: I am a beginner myself, so this is just the way I would do it.)(I would use C# & XNA (Texture2D) for the manipulation)1. Load the File into your programm. -> Image2. pseudo code:for (int x = 0; x<Image.WIDTH; x++)  {    for (int y = 0; y<Image.HEIGHT; y++) {if(Image[x,y].alpha < 5)    {Image[x,y].red = 100;Image[x,y].green = 100;Image[x,y].blue = 100;    } }  }3. Stream back to a file.This site may be helpful too: http://www.libpng.org/pub/png/   ;Quote:Original post by sunrisefeTo a png file(four color channel), how  to change pixel's red,green and blue value to 100 respectively if its alpha value is smaller than 5. How to realize it? Any clue is appreciated.You can use linux or windows, gimp, c++, c#, haskell, SDL or SFML, hungarian notation, 1tbs, and unit testing, etc.No, seriously, you need to be way more specific about what you have already have done, or what you are looking for.   ;  Yup, PNG is magic.I mean, sorry to say that (and not helping) but working with a file is not rocket science.Are you able to open a file?Are you able to read data from a file?Are you able to write data to a file?Or it's just the PNG format, that you don't know about (and google either)?It's pretty surprising, that people cannot solve even trivial tasks. I'm beginning to think, that I'm a freaking genius.Sorry, I had a shit day.   ;Quote:Original post by szecsIt's pretty surprising, that people cannot solve even trivial tasks. I'm beginning to think, that I'm a freaking genius.Hmm. I am slightly confused as for Trinavartas reply. Maybe the non-newbies think too complicated. For another example, see this freaky thread.   ;Quote:Original post by phresnelHmm. I am slightly confused as for Trinavartas reply. Maybe the non-newbies think too complicated. For another example, see this freaky thread.I guess I would be laughing, if I weren't starving to death.But who am I to judge anyone? I can't even quote properly.   ;  I want to do in DX, and operate like follows, but the result file is not what I want. I dont know where is wrong. My operate is as follows://1. load original leaf png fileQuote:IDirect3DTexture9* pLeafTex = NULL;if(D3D_OK != D3DXCreateTextureFromFile(Device,"leaf.png",&pLeafTex)) MessageBox(NULL,"fail to load leaf texture！","ERROR",0);//2. get the width and height of original file, but here is something different. Original file is 200*270, but now what I get is 256*512Quote:D3DSURFACE_DESC dd;pLeafTex->GetLevelDesc(0,ⅆ);int leafWidth = dd.Width;//leaf's widthint leafHeight = dd.Height;//leaf's height//3. lock the texture object and operate on itQuote:D3DLOCKED_RECT LockedRect;if(pLeafTex->LockRect(0,&LockedRect,NULL,0) != D3D_OK)MessageBox(NULL,"fail to lock texture！","ERROR",0);{D3DXVECTOR4* pColor = (D3DXVECTOR4*)LockedRect.pBits;int pitch = LockedRect.Pitch / sizeof(D3DXVECTOR4);for (int row = 0; row < leafHeight; row++){for (int col = 0; col < leafWidth; col++){if ( pColor[pitch * row + col].w > 5 ){pColor[pitch * row + col].x = 100;pColor[pitch * row + col].y = 100;pColor[pitch * row + col].z = 100;} }}}pLeafTex->UnlockRect(0);//4. save leaf texture to png fileQuote:if (D3DXSaveTextureToFile("newLeaf.png", D3DXIFF_PNG, pLeafTex, NULL) != D3D_OK)MessageBox(NULL,"fail to save texture","ERROR",0);;  Have you read and understood the documentation for each of the functions that you use? In particular, what does D3DXCreateTextureFromFile do?   ;Quote:Original post by Nik02Have you read and understood the documentation for each of the functions that you use? In particular, what does D3DXCreateTextureFromFile do?To operate the original png file, I use D3DXCreateTextureFromFile to read png file to one texture object and operate it.  What is the matter?;Quote:Original post by sunrisefeI want to do in DX, and operate like follows, but the result file is not what I want. I dont know where is wrong. My operate is as follows:if ( pColor[pitch * row + col].w > 5 )Change that to:if ( pColor[pitch * row + col].w < 5 )And it should give you the result you are after.   