導航:首頁 > 編程語言 > php圖片邊框

php圖片邊框

發布時間:2023-06-02 13:08:15

php裁剪 動態裁剪框,要求生成固定大小的圖片

<?php
$sourcefile = 'x.jpg';
#目標寬度
$newwidth = 150;
#目標高度
$newheight = 120;
#目標比例
$newbili = $newwidth / $newheight;

#源圖片寬高
list($width, $height) = getimagesize($sourcefile);

if($width / $height > $newbili){
#原圖較長
$w = $width - $newbili * $height;
$h = $height;
$x = ($width - $w) / 2;
$y = 0;
}else{
#原圖較寬
$w = $width;
$h = $height - $newbili * $width;
$x = 0;
$y = ($height - $h) / 2;
}

$source = imagecreatefromjpeg($sourcefile);
$thumb = imagecreatetruecolor($newwidth, $newheight);

imageresized($thumb, $source, 0, 0, $x, $y, $newwidth, $newheight, $w, $h);
imagejpeg($thumb, "a.jpg");

註:此程序未考慮原圖比目標圖片小的情況

❷ 為什麼我使用php的imagerectangle()函數繪制的矩形邊框會是這個樣子

程序是從0開始計算的,樓主畫布只有100*100,
此處
imagerectangle( $image, 0, 0, 100, 100, $red );
改成
imagerectangle( $image, 0, 0, 99,99, $red );
試一試

❸ 用php寫一個簡單登錄界面,怎麼給它加入一張背景圖片啊,用div框該怎麼弄,或者其他的方法

背景圖像載入很簡單,你只需要做以下幾步即可(假設你的登陸界面對話框類名叫「CLoginDlg」):
(1)菜單「Insert」->"Resource",選擇Bitmap,然後點「Import...」,選擇你的背景圖像,然後假設該資源ID為「IDB_BITMAP1」;
(2)在LoginDlg.h下聲明一個CBitmap m_BKbitmap;
(3)在LoginDlg.cpp的構造函數中:m_BKbitmap.LoadBitmap(IDB_BITMAP1);
(4)在LoginDlg.cpp的OnPaint()函數中寫上:
void CLoginDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
BITMAP bm;
CRect rect;
CDC dcMem;
m_BKbitmap.GetBitmap (&bm);
GetClientRect(&rect);
dcMem.CreateCompatibleDC (&dc);
CBitmap *oldbitmap=dcMem.SelectObject (&m_BKbitmap);
dc.BitBlt (0,0,bm.bmWidth ,bm.bmHeight ,&dcMem,0,0,SRCCOPY);
dcMem.SelectObject(oldbitmap);
CDialog::OnPaint();
}
}
你的問題就OK了。
關於按鈕控制項顯示圖片,建議你可以下載一個CButton的繼承類,什麼「CButtonST」啊、「CBtnST」啊、「CDlgShadeButtonST」啊,自己手寫的話不劃算,有很多現成的控制項類,都寫的非常好,完全可以拿來為我們所用。

閱讀全文

與php圖片邊框相關的資料

熱點內容
肉特別多的電影 瀏覽:970
好的在觀看網站 瀏覽:307
vip免費影視劇網站 瀏覽:924
恐怖鬼片免費版在線觀看 瀏覽:539
印度神話電影排行前十 瀏覽:510
主角開飛機重生流 瀏覽:760
java函數式編程教程 瀏覽:271
天正圖紙加密後的效果 瀏覽:909
泰安汽車解壓郵政網點 瀏覽:410
泰國鬼片在線觀看免費收看 瀏覽:695
彼時曾相伴免費觀看完整版 瀏覽:254
網站在線觀看什 瀏覽:159
食嬰鬼整部電影 瀏覽:360
印度電影愛經 瀏覽:642
搜播比神馬更好看的影視 瀏覽:82
特警力量同人小說 瀏覽:253
葉天明柳韻為主角的小說全文免費閱讀 瀏覽:929
比愛戀尺度大的電影 瀏覽:135
主人公叫楊凡的小說 瀏覽:860
在船上做皮肉生意的電影 瀏覽:655