有人可以幫我解決png圖的問題嗎.... |
尚未結案
|
patrick83
一般會員 發表:2 回覆:0 積分:0 註冊:2005-08-25 發送簡訊給我 |
以下是程式碼....
我是要將png圖變小張....
但我一直縮不到,他只是把外框縮小圖沒變小,而且還變白色....
不知道出了甚麼原因...
謝謝.... void __fastcall TForm1::OpenPNGButtonClick(TObject *Sender)
{
if (OpenDialog1->Execute())
{
TCHAR filename[MAX_PATH];
lstrcpyn(filename, OpenDialog1->FileName.c_str(), MAX_PATH); // declare and clear the PNGD_P2DINFO structure
PNGD_P2DINFO png2dib;
memset(&png2dib, 0, sizeof(PNGD_P2DINFO)); // initialize the structure size and filename
png2dib.structsize = sizeof(PNGD_P2DINFO);
png2dib.pngfn = filename; // convert from PNG to DIB
if (read_png_to_dib(&png2dib) == PNGD_E_SUCCESS)
{
int x,y;
int n = 0, m = 0, i = 0, j = 0; Graphics::TBitmap* Bitmap = new Graphics::TBitmap;
Graphics::TBitmap* temp = Image1->Picture->Bitmap;
temp->Width = png2dib.lpdib->biWidth/2;
temp->Height = png2dib.lpdib->biHeight/2;
for(y = 0; y <= temp->Height; y++) {
if(y == m){
for(x = 0; x <= temp->Width; x++) {
if(x == n) {
Bitmap->Canvas->Pixels[j][i] = temp->Canvas->Pixels[y][x];
n = n + 2;
i++;
}
}
n = 0;
i = 0;
j++;
m = m + 2;
} } HBITMAP hBmp = Bitmap->ReleaseHandle();
HDC hDC = Canvas->Handle;
try
{
//
// TODO: add palette support...
// // convert from DIB to TBitmap
SetDIBits(
hDC, hBmp, 0,
png2dib.lpdib->biHeight, png2dib.bits,
reinterpret_cast
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |