This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
cg = player.ActiveInventory.Graphic;
inv_curs = DynamicSprite.CreateFromExistingSprite(cg, true);
alphaSprite = DynamicSprite.CreateFromExistingSprite(cg, true);
//get alpha "color" for each pixel of the 120x120 image
int x, y, alpha;
while (y < alphaSprite.Height)
{
while (x < alphaSprite.Width)
{
//code referencing x and y here
alpha = GetAlpha(cg, x, y);
DrawingSurface *ds = inv_curs.GetDrawingSurface();
ds.DrawingColor = Game.GetColorFromRGB(alpha,alpha,alpha); //this is grey
ds.DrawPixel(x,y);
x++;
}
y++;
x = 0;
}
Quote
Yea, although I looked through khris' module and I'm not 100% sure how it works... I are not as clever as Khris.
But!
As a very poor work around you could make a copy of the sprite using the GetAlpha and then run khris resize on that and then once it has been resized, plug the values back into the sprite.. so something like this.
Make a copy of your sprite at full size
iterate through each pixel of the original using GetAlpha to get its value.
Draw on the copy a grey value representing the alpha.
like:
Code:
alpha = GetAlpha(orig.Graphic, x, y);
ds.DrawingColor = Game.GetColorFromRGB(alpha,alpha,alpha); //this is grey
ds.DrawPixel(x,y);
then resize both your original and copy(which contains the alphas)
then iterate through the pixels again putting the alpha back into the original in accordance with the grey values stored in the copy.
This method might not be as inefficient as it seems since I dont think you can keep the drawingsurface open whilst running GetAlpha or PutAlpha so this way you only have to get/release the drawing surfaces a handful of times.
cg = player.ActiveInventory.Graphic;
inv_curs = DynamicSprite.CreateFromExistingSprite(cg, true); // create sprite
alphaSprite = DynamicSprite.CreateFromExistingSprite(cg, true);
//get alpha "color" for each pixel of the 120x120 image
int x = 0;
int y = 0;
while (x <= some code here to process each pixel in a 120x120 image)
{
alpha = GetAlpha(cg.Graphic, x, y);
DrawingSurface *ds = alphaSprite.GetDrawingSurface();
ds.DrawingColor = Game.GetColorFromRGB(alpha,alpha,alpha); //this is grey
ds.DrawPixel(x,y);
}
//resize both the cursor sprite and the "alpha sprite" with Bilinear
alphaSprite.ResizeFilter(alphaSprite.Width/2, alphaSprite.Height/2, eFilterBilinear);
inv_curs.ResizeFilter(inv_curs.Width/2, inv_curs.Height/2, eFilterBilinear);
//copy the alpha values of the "alpha sprite" into the cursor sprite for each pixel
int x = 0;
int y = 0;
while x <= (some code here to process each pixel in a 120x120 image)
{
alpha = GetAlpha(alphaSprite.Graphic, x, y);
PutAlpha((inv_curs.Graphic, x, y, alpha);
}
Quoteyea the way you describe is essentially the only way to do it. The GetAlpha() and PutAlpha() functions can do for the alpha what khris' module does for the RGB
GUI gBloodSplatter is larger than the screen size and may cause errors in the game.
//if (c == -1) c = magic_pink;
do.Clear();
(DrawAlpha(Buffer.CursorGraphic, 1827, 0, 0, 0);)
clearSprite = DynamicSprite.CreateFromExistingSprite(Buffer.Graphic);
DrawingSurface *surface = clearSprite.GetDrawingSurface();
surface.Clear();
Buffer.Graphic = clearSprite.Graphic;
surface.Release();
Error: DynamicSprite.CreateFromExistingSprite: sprite 1834 does not exist
void clearThisSprite(InventoryItem *Buffer)
{
//DrawAlpha(Buffer.CursorGraphic, 1827, 0, 0, 0);
clearSprite = DynamicSprite.CreateFromExistingSprite(Buffer.CursorGraphic);
DrawingSurface *surface = clearSprite.GetDrawingSurface();
surface.Clear();
Buffer.CursorGraphic = clearSprite.Graphic;
surface.Release();
}
void drawResumeItemCursor()
{
clearThisSprite(iBufferItem132);
DrawAlpha(iBufferItem132.CursorGraphic, player.ActiveInventory.CursorGraphic, 0, 0, 0);
//draw Resume Arrow over the item's cursor into sprite iBufferItem132.CursorGraphic
DrawAlpha(iBufferItem132.CursorGraphic, 1826, 0, 0, 0);
mouse.ChangeModeGraphic(eModePointer, iBufferItem132.CursorGraphic);
mouse.ChangeModeHotspot(eModePointer, 65, 34);
}
if (mouse.Mode == eModeSelectInv || mouse.Mode == eModeUseinv) //save the "Resume with Item" cursor graphic to a variable
{
//clear sprite 132 so it can be drawn to
clearThisSprite(iBufferItem132);
//draw default cursor onto empty sprite 132, save it temporarily
DrawAlpha(iBufferItem132.Graphic, overItem.CursorGraphic, 0, 0, 0);
bDrawn = false;
}
void clearThisSprite(InventoryItem *Buffer)
{
DrawAlpha(Buffer.Graphic, 1827, 0, 0, 0);
//clearSprite = DynamicSprite.CreateFromExistingSprite(Buffer.Graphic);
//DrawingSurface *surface = clearSprite.GetDrawingSurface();
//surface.Clear();
//Buffer.Graphic = clearSprite.Graphic;
//surface.Release();
}
void drawResumeItemCursor()
{
clearThisSprite(iBufferItem133);
//draw 132 default item image onto empty sprite 133
DrawAlpha(iBufferItem133.Graphic, 132, 0, 0, 0);
//draw Resume Arrow over the item's cursor into sprite 133
DrawAlpha(iBufferItem133.Graphic, 1826, 0, 0, 0);
mouse.ChangeModeGraphic(eModePointer, iBufferItem133.Graphic);
mouse.ChangeModeHotspot(eModePointer, 65, 34);
}
void clearThisSprite(InventoryItem *Buffer)
{
//DrawAlpha(Buffer.Graphic, 1827, 0, 0, 0);
clearSprite = DynamicSprite.CreateFromExistingSprite(Buffer.Graphic);
DrawingSurface *surface = clearSprite.GetDrawingSurface();
surface.Clear();
Buffer.Graphic = clearSprite.Graphic;
surface.Release();
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.211 seconds with 16 queries.