That is just how some browsers display PNGs with alpha. Try to open it in some
image editor (that supports PNGs with alpha).
image editor (that supports PNGs with alpha).
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.
procedure DrawPixelAlpha(Canvas: TImagingCanvas; X, Y: Integer; Alpha: Byte);
var
ColRec: TColor32Rec;
begin
ColRec.Color := Canvas.Pixels32[X, Y];
ColRec.A := Alpha;
Canvas.Pixels32[X, Y] := ColRec.Color;
end;
procedure DrawAlphaEllipse(Canvas: TImagingCanvas; const Rect: TRect; Alpha: Byte; Fill: Boolean);
var
RadX, RadY, DeltaX, DeltaY, R, RX, RY: LongInt;
X1, X2, Y1, Y2, Bpp, OldY, I: LongInt;
Color: PColor32Rec;
begin
X1 := Rect.Left;
X2 := Rect.Right;
Y1 := Rect.Top;
Y2 := Rect.Bottom;
SwapMin(X1, X2);
SwapMin(Y1, Y2);
RadX := (X2 - X1) div 2;
RadY := (Y2 - Y1) div 2;
Y1 := Y1 + RadY;
Y2 := Y1;
OldY := Y1;
DeltaX := (RadX * RadX);
DeltaY := (RadY * RadY);
R := RadX * RadY * RadY;
RX := R;
RY := 0;
if Fill then
begin
for I := X1 to X2 do
DrawPixelAlpha(Canvas, I, Y1, Alpha);
end;
DrawPixelAlpha(Canvas, X1, Y1, Alpha);
DrawPixelAlpha(Canvas, X2, Y1, Alpha);
while RadX > 0 do
begin
if R > 0 then
begin
Inc(Y1);
Dec(Y2);
Inc(RY, DeltaX);
Dec(R, RY);
end;
if R <= 0 then
begin
Dec(RadX);
Inc(X1);
Dec(X2);
Dec(RX, DeltaY);
Inc(R, RX);
end;
if (OldY <> Y1) and Fill then
begin
for I := X1 to X2 do
DrawPixelAlpha(Canvas, I, Y1, Alpha);
for I := X1 to X2 do
DrawPixelAlpha(Canvas, I, Y2, Alpha);
end;
OldY := Y1;
DrawPixelAlpha(Canvas, X1, Y1, Alpha);
DrawPixelAlpha(Canvas, X2, Y1, Alpha);
DrawPixelAlpha(Canvas, X1, Y2, Alpha);
DrawPixelAlpha(Canvas, X2, Y2, Alpha);
end;
end;
// draw ellipse
DrawAlphaEllipse(Canvas, Rect(16, 64, 240, 192), 55, True);
// draw square
for I := 128 to 255 do
for J := 128 to 255 do
DrawPixelAlpha(Canvas, I, J, 200);
var
OrigImage, SmallImage: TSingleImage;
Texture: IDirect3DTexture9;
D3DDevice: IDirect3DDevice9;
.... init D3D ....
.... create orig image, say 1024x1024 pixels ....
SmallImage := TSingleImage.CreateFromParams(256, 256, OrigImage.Format); // create small image
OrigImage.CopyTo(512, 512, SmallImage.Width, SmallImage.Height, SmallImage, 0, 0); // copy from orig to small
CreateD3DTextureFromImage(SmallImage.ImageDataPointer^, D3DDevice, Texture); // create texture from small image
var
Image: TSingleImage;
Texture: IDirect3DTexture9;
Rect: TD3DLockedRect;
PixelPtr, DestPtr: Pointer;
X, Y, I, LineBytes, TextureSize: Integer; // say TextureSize is 128, [X, Y] is source position in image
.... create your texture and image ....
Texture.LockRect(0, Rect, nil, 0); // lock texture
LineBytes := Image.FormatInfo.GetPixelsSize(Image.FormatInfo.Format, TextureSize, 1);
for I := 0 to TextureSize - 1 do
begin
Move(Image.PixelPointers[X, Y + I]^, // move pixels from image to texture
PByteArray(Rect.pBits)[I * Rect.Pitch], LineBytes);
end;
Texture.UnlockRect(0); // unlock texture
var
Img: TSingleImage;
Src, Bitmap: PByte;
begin
... load or create image ...
// First convert image to 8bpp grayscale
Img.Format := ifGray8;
Src := Img.Bits;
// Create bilevel image using 128 as treshold
for Y := 0 to Img.Height - 1 do
for X := 0 to Img.Width - 1 do
begin
if Src^ > 128 then
Src^ := 255
else
Src^ := 0;
Inc(Src);
end;
// Allocate memory for 1bpp image
WidthBytes := (Img.Width + 7) div 8; // Scanlines size must be byte-aligned
GetMem(Bitmap, WidthBytes * Img.Height);
FillChar(Bitmap^, WidthBytes * Img.Height, 0); // Needed by conversion code
Src := Img.Bits;
// Now copy pixels to Bitmap
for Y := 0 to Img.Height - 1 do
for X := 0 to Img.Width - 1 do
begin
Bitmap[Y * WidthBytes + X div 8] := Bitmap[Y * WidthBytes + X div 8] or // OR current value of byte with following:
(Src^ and 1) // To make 1 from 255, 0 remains 0
shl (7 - (X mod 8)); // Put current bit to proper place in byte
Inc(Src);
end;
QuoteJust have to look at the API.
Page created in 0.023 seconds with 15 queries.