I located the alphamap code. Ensure you set your draw buffer
to 0xFFFF. Remember, it is possible to still blow the draw buffer
if the map is too large, and there is no way to verify that you
blew the buffer. You can use the ctx for anything you want,
I just used it for a success/failure boolean. As mentioned
in my previous post, you may have to comment out the RGB part
of the ‘if’ statement.
Regards.
static void func(void * ctx, const PhPoint_t *pos, const FontRender * render)
{ int * bad = (int *)ctx;
if(render->bpp == 1)
{ PhDrawContext_t *cur_dc = (Ph->draw_context);
PhImage_t tsImage;
PgColor_t palette[2] = { Pg_WHITE, CUR_GC->text.com.primary };
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
tsImage.bpl = render->bpl;
tsImage.image = render->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
tsImage.type = Pg_BITMAP_TRANSPARENT;
if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{ (*bad) = 1;
}
}
else if(render->bpp == 4)
{ PhDrawContext_t *cur_dc = (Ph->draw_context);
PhImage_t tsImage;
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
tsImage.bpl = render->bpl;
tsImage.image = render->bmptr;
tsImage.palette = NULL;
tsImage.colors = 0;
tsImage.type = Pg_IMAGE_GBLEND_NIBBLE;
if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{ (*bad) = 1;
}
}
else if(render->bpp ==
{ if(render->flags & FONTRENDER_RGB_PIXMAP)
{ PhImage_t tsImage;
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = render->size.x;
tsImage.size.h = render->size.y;
tsImage.bpl = render->bpl;
tsImage.image = render->bmptr;
tsImage.colors = 0;
tsImage.palette = NULL;
tsImage.type = Pg_IMAGE_DIRECT_888;
if(PgDrawPhImagemx(pos, &tsImage, 0x00) == -1)
{ (*bad) = 1;
}
}
else
{ PgMap_t alpha;
PgColor_t old;
PhDrawContext_t *cur_dc = (Ph->draw_context);
PhRect_t rect;
rect.ul.x = pos->x;
rect.ul.y = pos->y;
rect.lr.x = (rect.ul.x + render->size.x) - 1;
rect.lr.y = (rect.ul.y + render->size.y) - 1;
PgAlphaOn();
alpha.map = render->bmptr;
alpha.dim.w = render->size.x;
alpha.dim.h = render->size.y;
PgSetAlphaBlend(&alpha, 0x00);
old = PgSetFillColor(CUR_GC->text.com.primary);
PgDrawRect(&rect, Pg_DRAW_FILL);
PgSetFillColor(old);
PgSetAlphaBlend(NULL, 0x00);
PgAlphaOff();
}
}
else
{ (*bad) = 1;
}
return;
}
Derek Leach <dleach@dleach.qnx.com> wrote:
phearbear@home.se> > wrote:
hi everyone
I’m using PfRenderCx to render text using fractional scaling, It almost
work, to the exception that I don’t know what type the bmptr is in the
callback.
the bpp argument say ‘8’ which isn’t in the docs.
I assume the bmptr is a type of gradient, Pg_IMAGE_GRADIENT_BYTE, and
drawing the imgae using that almost works, I get really wacko colors etc.
How do I setup the Palette correctly? I tried using the PgSet…Color
with no success. How do I create a gradient palette?
8bpp indicates a 256 gray scale map. You can do the following
to display it as a “pixmap”, but the graphics driver actually
uses it as an alphamap. I do not recommend taking the alphamap
route, since it is possible to exceed the size of the draw buffer.
All the graphics driver alpha requests are within the same
process, therefore it does not have to worry about this limitation.
If you really want the alphamap code, I will have to find it.
I did it awhile back, and cannot easily locate it.
Regards.
void render_cb(void * ctx, const PhPoint_t * pktsPnt, const FontRender * pktsRender)
{ PhImage_t tsImage;
PhPoint_t tsPos = { 0, 0 };
PgColor_t palette[2] = { Pg_WHITE, Pg_BLACK };
memset(&tsImage, 0x00, sizeof(PhImage_t));
tsImage.size.w = pktsRender->size.x;
tsImage.size.h = pktsRender->size.y;
tsImage.bpl = pktsRender->bpl;
tsImage.image = pktsRender->bmptr;
tsImage.palette = palette;
tsImage.colors = 2;
if(pktsRender->bpp == 1)
{ tsImage.palette = NULL;
tsImage.type = Pg_BITMAP_BACKFILL;
}
else if(pktsRender->bpp == 4)
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_NIBBLE;
}
else if(pktsRender->bpp == >
{ if(pktsRender->flags & FONTRENDER_RGB_PIXMAP) // You may have to skip this part of the if,
{ tsImage.palette = NULL; // it may not be defined on all systems.
tsImage.type = Pg_IMAGE_DIRECT_888; //
} //
else //
{ palette[0] = Pg_WHITE;
palette[1] = Pg_BLACK;
tsImage.type = Pg_IMAGE_GRADIENT_BYTE;
}
}
if(PgDrawPhImagemx(&tsPos, &tsImage, 0x00) == -1)
{ printf(“Ouch!!\n”);
}
PgFFlush(1);
return;
}