① 請問aspimage的詳細使用方法
使用ASPImage組件僅需以下步驟:
建一個對象
設置若干屬性
調用SaveImage方法
以下代碼舉例說明如何在vbscript中使用ASPImage組件,在這個例子中我們要建立一個漸進填充的字樣為 "welcome to"的文字圖片:
Set Image = Server.CreateObject("AspImage.Image")
rem Set various font parameters
Image.FontColor = vbBlack
Image.Italic = True
Image.Bold = True
Image.FontName = "Arial"
Image.FontSize = 12
Image.PadSize = 10
rem Calculate how big our text info is and set the image to this size
rem This has to be done since we want to fill the area with a gradient
strMessage = "Welcome to"
Image.MaxX = Image.TextWidth (strMessage)
Image.MaxY = Image.TextHeight (strMessage)
rem Create a one way gradient
Image.GradientOneWay vbRed, vbWhite, 0
rem Print our string to the image
Image.TextOut strMessage, Image.X, Image.Y, false
rem Set the filename and save
rem NOTE: You should gen the filename dynamically for multiuser usage
Image.FileName = "d:\inetpub\wwwroot\images\msg1.jpg"
if Image.SaveImage then
rem The image was saved so write the <img src> tag out for the browser to pick up
Response.Write "<img src=""/images/msg1.jpg""><br>"
else
rem Something happened and we couldn't save the image so just use an HTML header
rem We need to debug the script and find out what went wrong
Response.Write "<h2>Welcome to</h2>
end if
通過使用SaveImage方法我們可以得知圖片是否已經正確保存了。一般導致圖片不能正確保存的原因是圖片的保存路徑不合法或者對該路徑沒有寫的許可權。
GIF Animations
圖片能被載入或進行處理,並且可以通過調用AddImage方法將這些修改保存到一個活動順序的動畫中。在soianim.asp中有個簡單的GIF動畫例子,這個文件已打包到ASPImage的ZIP文件中。
② 求java中Image類的使用,最好能有幾個簡單的例子,不要給我什麼幫助文檔啊,我自己有幫助文檔。
這個是生成隨即圖片驗證碼的例子
package org.web.servlet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class RandomCode extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = -8636059798367365083L;
public static final String RANDOMCODE = "RANDOMCODE";//session定義
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "No-cache");
response.setDateHeader("Expires", 0);
int width = 80, height = 23;
BufferedImage img = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Random random = new Random();
Graphics g = img.getGraphics();
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height);
// 設定字體
g.setFont(new Font("Verdana", Font.ITALIC + Font.PLAIN, 18));
// 設定隨機字體
//設置背景顏色
//g.setColor(new Color(random.nextInt(250),random.nextInt(250),random.nextInt(250)));
// 畫邊框
g.setColor(new Color(33, 66, 99));
g.drawRect(0, 0, width - 1, height - 1);
// 隨機產生50條干擾線,使圖象中的認證碼不易被其它程序探測到
//g.setColor(getRandColor(100, 150));
g.setColor(new Color(200,200,200));
for (int i = 0; i < 50; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
String[] randStr = {"0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F","G","H","I","J","K",
"L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
// 取隨機產生的認證碼(6位數字)
String sRand = "";
for (int i = 0; i < 5; i++) {
String rand = String.valueOf(randStr[random.nextInt(randStr.length-1)]);
sRand += rand;
// 將認證碼顯示到圖象中
// 設置字體顏色
//g.setColor(this.getRandColor(40, 60));
g.setColor(new Color(random.nextInt(100),random.nextInt(100),random.nextInt(100)));
g.drawString(rand, 13 * i + 6, 16);
}
// 將認證碼存入SESSION
HttpSession session = request.getSession();
session.setAttribute(RandomCode.RANDOMCODE, sRand);
// 釋放圖形上下文
g.dispose();
// 輸出圖象到頁面
ImageIO.write(img, "JPEG", response.getOutputStream());
}
private Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255) {
fc = 255;
}
if (bc > 255) {
bc = 255;
}
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
}
③ 第三節 Flutter Image圖片組件的使用
Image組件的構造方法
在 Android 中,我們都知道,圖片的顯示方式有很多,資源圖片、網路圖片、文件圖片等等,在 Flutter 中也有多種方式,用來載入不同形式的圖片:
Image:通過ImageProvider來載入圖片
Image.asset:用來載入本地資源圖片
Image.file:用來載入本地(File文件)圖片
Image.network:用來載入網路圖片
Image.memory:用來載入Uint8List資源(byte數組)圖片
Image 的一個參數是 ImageProvider,基本上所有形式的圖片載入都是依賴它,這個類裡面就是實現圖片載入的原理。用法如下:
載入一個本地資源圖片,和 Android 一樣,有多種解析度的圖片可供選擇,但是沿襲的是 iOS 的圖片風格,分為 1x,2x,3x,具體做法是在項目的根目錄下創建兩個文件夾,如下圖所示:
還要配置如下
在pubspec.yaml文件
載入一個本地 File 圖片,比如相冊中的圖片,用法如下
載入一個網路圖片,用法如下:
有的時候我們需要像Android那樣使用一個占點陣圖或者圖片載入出錯時顯示某張特定的圖片,這時候需要用到 FadeInImage 這個組件:
用來將一個 byte 數組載入成圖片,用法如下:
④ delphi中image的使用方法
你可以這樣:
Image1.Picture.LoadFromFile('d:\aa.bmp');
一般設計程序時候,從規范上考慮,也為安裝方便,一般把程序調用的資源(如圖片\動畫\視頻)等放到程序相同的目錄,然後調用.
比如你把圖片放到和程序執行同目錄下的res文件夾中,可如下調用:
Image1.Picture.LoadFromFile(ExtractFilePath(paramstr(0))+'res\aa.bmp');
⑤ 關於java里image的用法
先要設置圖片路徑,我們將一將背景圖片back.jpg放到C盤的img目錄下,調用語句如下:
ImageIcon icon=new ImageIcon("C:\\img\\back.jpg),一定要是雙反斜杠
然後分別在JComponent里添加圖片
JFrame
利用JFrame的一個方法setIconImage(Image image);
由於要用到Image類,所以還得把上面定義的ImageIcon對象轉換成Image對象:
Image image=icon.getImage();
然後就可以調用JFrame的setIconImage(image)方法了。
還要注意一點的是,由於有些圖片的格式JVM不能識別,所以要轉格式,一般為jpg,gif.如把.bmp格式的轉換為.jpg,不能簡單的把後綴名改了就行,這樣照樣不能顯示。方法很簡單,直接用WINDOWS自帶的畫圖工具打開圖片,然後另存為時改為.jpg或.gif格式就可以了。
附源代碼
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.JTree;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.FlowLayout;
public class ImageTest extends JFrame{
ImageIcon icon=new ImageIcon("c:\\img\\system.jpg");
Image image=icon.getImage();
public ImageTest()
{
JMenuBar mb=new JMenuBar();
this.setJMenuBar(mb);
JMenu menu=new JMenu("system");
menu.setIcon(icon);
//JMenuItem item=new JMenuItem("exit",icon);
JMenuItem item=new JMenuItem(icon);
item.setIcon(icon);
JLabel label=new JLabel(icon);
//label.setIcon(icon);
menu.add(item);
mb.add(menu);
DefaultMutableTreeNode root=new DefaultMutableTreeNode();
DefaultMutableTreeNode node1=new DefaultMutableTreeNode();
DefaultMutableTreeNode node11=new DefaultMutableTreeNode();
DefaultMutableTreeNode node12=new DefaultMutableTreeNode();
DefaultMutableTreeNode node2=new DefaultMutableTreeNode();
DefaultMutableTreeNode node21=new DefaultMutableTreeNode();
root.add(node1);
root.add(node2);
node1.add(node11);
node1.add(node12);
node2.add(node21);
JTree jTree1 = new javax.swing.JTree(root);
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(new ImageIcon("C:\\img\\down.jpg")); //展開時節點圖標
renderer.setClosedIcon(new ImageIcon("C:\\img\\file.jpg")); //折疊時節點圖標
renderer.setLeafIcon(new ImageIcon("C:\\img\\man_small.jpg")); //葉子節點圖標
jTree1.setCellRenderer(renderer);
this.add(label);
this.setIconImage(image);
this.add(jTree1);
this.setDefaultCloseOperation(3);
this.setLocation(300,400);
this.pack();
this.setVisible(true);
}
public static void main(String[] args)
{
new ImageTest();
}
}
⑥ silverlight,中的圖片對象Image 的使用方法
Silverlight2 beta2現在支持的Image格式有jpg和png,部分png編碼也不支持,同時有些png在xaml的design預覽中不可見,但運行時可見。請看XAML markup中兩行代碼的異同:
<Image x:Name="img" Source="test.jpg" /><Image x:Name="img2" Source="/test2.jpg" />反斜杠forward-slash?有沒有蝦米區別呢?建立一個名稱為pan的Silverlight應用程序工程,解決方案資源管理器如圖所示。第一種方式(不以反斜杠開頭)的圖片test.jpg應該放在pan目錄下才可正確引用,而第二種方式,圖片test2.jpg必需放在ClientBin目錄下,否則會發生ImageError。
為什麼呢?反斜杠開頭說明該URI是一個相對路徑,而程序運行時的根目錄為ClientBin,因此test2.jpg的位置應該調整。不過此時在XAML的design預覽試中看不到test2.jpg圖片。如果圖片一樣,那麼運行結果是相同。如此一來,究竟選擇哪種方式呢?分別把兩種方式的xap文件重命名為zip,解壓之,並用reflector反編譯其中的dll文件,可以看到第一種方式(沒有/)resource里包含了test圖片,而第二種方式resource里卻沒有test2圖片。由此可知,第一種方式把圖片嵌入到Silverlight程序中直接下載到客戶端,而第二種方式則按需索取(on-demand),當顯示時再去下載。當數據量較大時,第一種方式載入程序的時間就過長,用戶體驗不好。而第二種方式優勢就比較明顯,只不過在xaml設計時預覽不方便,此時可以先把需要顯示的圖片除了放在ClientBin目錄下外,亦可先復制一份放在pan目錄下供設計使用,程序發布時再刪除。+++++++++++++++++++++++他們都說我是分割線+++++++++++++++++++++++++++++
事實上,不止是圖片,音頻、視頻,甚至XML和XAML等non-executable data files都是resource文件,處理方式類似。若深究,則資源文件可細分為Resource files 、Content files 、Site of origin files,可參考Silverlight Documentation的相關章節。參考下面的Silverlight Application組成,LionGG簡單講解下。
⑦ 求助Matlab的image和imagesc的用法
image函數是顯示圖像的最基本的方法。該函數還產生了圖像對象的句柄,並允許對對象的屬性進行設置。
imshow函數比image和imagesc更常用,它能自動設置句柄圖像的各種屬性。imshow可用於顯示各類圖像。對於每類圖像,調用方法如下:
• imshow filename:顯示圖像文件。
• imshow(BW):顯示二值圖像,BW為黑白二值圖像矩陣。
• imshow(X,map):顯示索引圖像,X為索引圖像矩陣,map為色彩圖示。
• imshow(I):顯示灰度圖像,I為二值圖像矩陣。
• imshow(RGB):顯示RGB圖像,RGB為RGB圖像矩陣。
• imshow(I,[low high]):將非圖像數據顯示為圖像,這需要考慮數據是否超出了所顯示類型的最大允許范圍,其中[low high]用於定義待顯示數據的范圍。imshow(I, [])自動調節數據范圍以便於顯示。
imagesc函數也具有image的功能,所不同的是imagesc函數還自動將輸入數據比例化,以全色圖的方式顯示。imagesc會對圖像灰度級做縮放處理,imshow不會縮放。
imagesc(A)將矩陣A中的元素數值按大小轉化為不同顏色,並在坐標軸對應位置處以這種顏色染色。
imagesc(x,y,A) x, y分別為二維向量,Matlab會在[x1,x2]*[y1,y2]范圍內染色。
⑧ delphi中的IMAGE控制項的用法
從路徑讀取圖片並顯示: Image1.Picture.LoadFromFile('E:\My Pictures\01.bmp');清除圖片: Image1.Picture.Assign(nil);更改圖片: Image1.Picture.LoadFromFile('E:\My Pictures\01.bmp'); //一樣的方法屬性: Center:居中 Seretch:縮小並填充 Proportional: 按比例縮小
⑨ vb image用法
image讀取:
Image1.Picture = LoadPicture(App.Path & "\1.jpg")
1.JPG在當前程序所在目錄,或
Image1.Picture = LoadPicture("C:\ABC\1.jpg")
1.JPG在「C:\ABC」的目錄中
如果圖片是提前不知道,需要變數控制:
DIM A AS STRING
A=TEXT1.TEXT
Image1.Picture = LoadPicture(App.Path & "/" & A & "")
TEXT1.TEXT中輸入當前目錄中的圖片名稱+擴展名
⑩ image的例句與用法
1. How can we improve our image?
我們該怎樣來改善自己的形象呢?
2. Her image rose before him.
她的影像在他眼前浮現。
3. I have this image of you as always being cheerful.
在我的心目中,你的樣子總是興高采烈的。
4. According to the Bible, God created man in his image.
據《聖經》所敘, 上帝按自己的形象創造了人.
5. She's the (spitting) image of her mother.
她長得活像她媽媽.
6. They concentrated on better definition of the optical image.
他們致力於提高該光學影像的鮮明度.
7. She is the express image of her mother.
她和她母親長得一模一樣。
8. This company is concerned about its corporate image.
這家公司關心它自身的法人形象。