Sunday, March 28, 2010

How to get image RGB/16???????? (cont)

VRect currentRect;



int32 progressTotal = tilesVert * tilesHoriz;

int32 progressDone = 0;



// process each tile in order



currentRect.top = 0;

currentRect.left = 0;

currentRect.bottom = tileHeight;

currentRect.right = tileWidth;



// don't go past the document bounds

if (currentRect.bottom %26gt; docHeight)

currentRect.bottom = docHeight;

if (currentRect.right %26gt; docWidth)

currentRect.right = docWidth;





pixelMemoryDesc.rowBits = (currentRect.right - currentRect.left) *

readChannelDesc-%26gt;depth;

// read

while(readChannelDesc != NULL)

{

bigError = sPSChannelProcs-%26gt;ReadPixelsFromLevel(

readChannelDesc-%26gt;port, 0, %26amp;currentRect, %26amp;pixelMemoryDesc);

if (bigError)

{

error = filterBadParameters;

throw(this);

}



/************************/





unsigned char *imageData;// for image RGB/8, with RGB/16 is unsigned short

long temp = tileHeight * tileWidth * readChannelDesc-%26gt;depth/8;

imageData = new unsigned char[temp];// for image RGB/8, with RGB/16 is unsigned short



memcpy(imageData, pixelMemoryDesc.data, temp);



FILE *file;



file = fopen(''C:\\abc.txt'', ''ab'');

if(file == NULL)

return;

fwrite(imageData, sizeof(unsigned char), temp, file);// for image RGB/8, with RGB/16 is unsigned short

fclose(file);

readChannelDesc = readChannelDesc-%26gt;next;

}

return;



}

////end of customizing/////



- then we use a project to read ''abc.txt'' to get image:



////////// function of button that is clicked, the image is shown

void CPixelDlg::OnBtnSetPixel()

{

// TODO: Add your control notification handler code here

//////////////////////////////////////////////////////////

// POINT point;

//////////////////////////////////////////////////

unsigned char*memblock;// for image RGB/8, with RGB/16 is unsigned short

memblock = new unsigned char[HEIGH * WIDTH *3];// HEIGH , WIDTH is assigned by hard code// for image RGB/8, with RGB/16 is unsigned short



FILE *file;



file = fopen(''C:\\abc.txt'', ''rb'');

if( file == NULL)

{

return;

}

else

{

fread(memblock, sizeof(unsigned char), HEIGH * WIDTH *3, file);// for image RGB/8, with RGB/16 is unsigned short

fclose(file);

}



//////////////////////////////////////////////////



CClientDC dc(this);

int i = 0;

int j=0;

int k = 0;

for( i = 0; i %26lt; WIDTH; i++)

{

for( j = 0; j %26lt; HEIGH; j++)

{



if (k%26gt;WIDTH*HEIGH*3-3)

break;



dc.SetPixel(j, i, RGB(memblock[k],memblock[k+WIDTH*HEIGH],memblock[k+2*WIDTH*HEIGH]));

k+=1;

}

}

}



2. that code is ok for Image RGB/8. But with image RGB/16, now we don't know how Photoshop stores image data, and how to get image data to show???

Please help me?

Thanks,
  • lips
  • No comments:

    Post a Comment