Copy link to clipboard
Copied
Many attempts failed.
sAIRaster->GetRasterInfo(this_art, &info);
artSlice.top = info.bounds.top;
artSlice.bottom = info.bounds.bottom;
artSlice.left = info.bounds.left;
artSlice.right = info.bounds.right;
artSlice.front = 0;
artSlice.back = info.bitsPerPixel / 8;
memcpy(&workSlice, &artSlice, sizeof(AISlice));
memset(&workTile, 0, sizeof(AITile));
memcpy(&workTile.bounds, &artSlice, sizeof(AISlice));
workTile.colBytes = (info.bitsPerPixel / 8);
workTile.planeBytes = 0;
workTile.rowBytes = info.bounds.right* info.bitsPerPixel;
int bts = info.bounds.right * info.bounds.bottom * info.bitsPerPixel ;
workTile.data = new char[bts];
memset(workTile.data, 0, bts);
for (size_t i = 0; i < info.bitsPerPixel / 8; i++)
workTile.channelInterleave[i] = i;
sAIRaster->GetRasterTile(this_art,&artSlice,&workTile,&workSlice);
char* date = (char*)workTile.data;
int onePixel = info.bitsPerPixel;
auto Print = [&](int x, int y, int i, AIArtHandle f) {
auto WWW = 1;
AIRealPoint xx;
xx.h = x * WWW;
xx.v = y * WWW;
AIRealPoint yy;
yy.h = xx.h + WWW;
yy.v = xx.v + WWW;
AIArtHandle artss;
sAIShapeConstruction->NewPointPointRect(xx, yy, false, false, false, false, &artss, 0);
CPathArt ssss(artss);
ssss.SetPathStroke(false);
AIColor cccc;
memset(&cccc, 0, sizeof(AIColor));
if (info.colorSpace == kCMYKColorSpace | kAlphaCMYKColorSpace)
{
auto GetV = [&](void* d, auto index) {
double* ccc = (double*)d;
ccc = ccc + index;
return (*ccc);
};
auto ff = GetV(date + onePixel * (workTile.bounds.right * y + x), i);
cccc.kind = kFourColor;
if (i == 0)
cccc.c.f.cyan = ff;
else if (i == 1)
cccc.c.f.magenta = ff;
else if (i == 2)
cccc.c.f.yellow = ff;
else if (i == 3)
cccc.c.f.black = ff;
else if (i == 4)
cccc.c.f.black = ff;
ssss.SetPathFill(true);
ssss.SetPathFill(cccc);
ssss.ReorderArt(kPlaceInsideOnTop, f);
};
auto Printf = [&](int index) {
CGroup gg;
gg.CreateGroup(CLayer().GetCurLayerArtHandle());
for (int i = 0; i < workTile.bounds.right; i++)
for (int j = 0; j < workTile.bounds.bottom; j++)
Print(i, j, index, gg.this_art);
};
for (size_t i = 0; i < info.bitsPerPixel / 8; i++)
Printf(i);
Who has a successful example thank!
Copy link to clipboard
Copied
many attempts to understand exactly what you're trying to do and what errors you're getting have failed.
Please elaborate and give us as much information as possible so that we can actually help. What's the goal? what do you have when you start? what do you want to have when you're finished. what is the context of this script? are you writing a CEP panel or just a script to execute on demand for a given file?
We're happy to help.. But i doubt you'll find anyone who'll blindly dig through your code to try and figure out what you want to do or what kind of problems could feasibly be occurring.
Copy link to clipboard
Copied
Thank you. I've solved it
Copy link to clipboard
Copied
care to share what the issue was? so that if someone else happens upon the same problem, they'll find this post and perhaps they'll be able to solve their problem as well.
Copy link to clipboard
Copied
//now Successful read AIRasterDate example for CMYK ACMYK
AISlice artSlice;
AITile workTile;
AISlice workSlice;
int index;
memset(&workTile, 0, sizeof(AITile));
artSlice.top = info.bounds.top;
artSlice.bottom = info.bounds.bottom;
artSlice.left = info.bounds.left;
artSlice.right = info.bounds.right;
artSlice.front = 0;
artSlice.back = info.bitsPerPixel / 8;
if (info.colorSpace & AIRasterColorSpace::kColorSpaceHasAlpha)
index = 1;
else
index = 0;
memcpy(&workSlice, &artSlice, sizeof(AISlice));
memcpy(&workTile.bounds, &artSlice, sizeof(AISlice));
workTile.colBytes = info.bitsPerPixel / 8;
workTile.planeBytes = 0;
workTile.rowBytes = info.byteWidth;
int bts = info.bounds.right * info.bounds.bottom * info.bitsPerPixel / 8 * sizeof(char);
workTile.data = new char[bts];
memset(workTile.data, 0, bts);
for (size_t i = 0; i < info.bitsPerPixel / 8; i++)
workTile.channelInterleave[i] = i;
char* date = (char*)workTile.data;
int onePixel = info.bitsPerPixel / 8;
auto Print = [&](int x, int y, int i, AIArtHandle f) {
auto WWW = 1;
AIRealPoint xx;
xx.h = x * WWW;
xx.v = y * WWW;
AIRealPoint yy;
yy.h = xx.h + WWW;
yy.v = xx.v + WWW;
AIArtHandle artss;
sAIShapeConstruction->NewPointPointRect(xx, yy, false, false, false, false, &artss, 0);
AIColor cccc;
memset(&cccc, 0, sizeof(AIColor));
auto GetV = [&](void* d, auto index) {
unsigned char* ccc = (unsigned char*)d;
ccc = ccc + index;
return (*ccc) / 255.0;
};
auto GetVAP = [&](void* d, auto index) {
unsigned char* ccc = (unsigned char*)d;
ccc = ccc + index;
return (*ccc) / 256.0;
};
// CMYK OR Alpha CMYK
if (info.colorSpace == kCMYKColorSpace | kAlphaCMYKColorSpace)
{
auto ff = GetV(date + onePixel * (workTile.bounds.right * y + x), i);
cccc.kind = kFourColor;
if (i == (index))
{
cccc.c.f.cyan = ff;
}
else if (i == (index+1))
{
cccc.c.f.magenta = ff;
}
else if (i == (index + 2))
{
cccc.c.f.yellow = ff;
}
else if (i == (index + 3))
{
cccc.c.f.black = ff;
}
//Alpha
if (index ==1 && i == 0)
{
cccc.c.f.black = GetVAP(date + onePixel * (workTile.bounds.right * y + x), i);
}
}
//CPathArt ssss(artss);
//ssss.SetPathStroke(false);
//ssss.SetPathFill(true);
//ssss.SetPathFill(cccc);
//ssss.ReorderArt(kPlaceInsideOnTop, f);
};
auto DebugPrintf = [&](int index) {
//CGroup gg;
//gg.CreateGroup(CLayer().GetCurLayerArtHandle());
for (int i = 0; i < workTile.bounds.right; i++)
for (int j = 0; j < workTile.bounds.bottom; j++)
Print(i, j, index, 0);//Print(i, j, index, gg.this_art);
};
for (size_t i = 0; i < info.bitsPerPixel / 8; i++)
DebugPrintf (i);
Copy link to clipboard
Copied