Skip to content

Instantly share code, notes, and snippets.

@jz5
jz5 / gist:7852906
Created December 8, 2013 03:07
Motorola S-record file read
initial begin
int fd, ret;
string line;
int type_no, size;
bit [31:0] addr;
bit [7:0] data []; // dynamic array
fd = $fopen("./hexfile", "r");
@jz5
jz5 / gist:7871285
Created December 9, 2013 12:04
URL から Bitmap の生成
Dim webBmp As Bitmap
Using wc = New WebClient
webBmp = New Bitmap(wc.OpenRead(url))
End Using
@jz5
jz5 / gist:7871310
Last active December 30, 2015 18:59
サーバーのディレクトリにある画像の読み込み
Dim wallBmp = New Bitmap(System.IO.Path.Combine(Server.MapPath("./"), "wallpaper.png"))
@jz5
jz5 / gist:7871317
Last active December 30, 2015 18:59
Content-Type image/png としてレスポンスを返す(画像の出力)
Response.ContentType = "image/png"
Response.Flush()
outBmp.Save(Response.OutputStream, Imaging.ImageFormat.Png)
Response.End()
@jz5
jz5 / gist:7871343
Created December 9, 2013 12:10
描画先の範囲に合せて、画像の合成 左右・上下に空きがないよう、Web 画像を拡大・縮小して必要な範囲を描画します。
Dim dst = New Rectangle(754, 18, 1110, 807) ' 描画先の位置・大きさ
Dim src = New Rectangle(0, 0, webBmp.Width, webBmp.Height) ' 参照画像の位置・大きさ
If dst.Width / dst.Height < webBmp.Width / webBmp.Height Then
Dim w = dst.Width / (dst.Height / webBmp.Height)
src.X = Convert.ToInt32((webBmp.Width - w) / 2)
src.Width = Convert.ToInt32(w)
Else
Dim h = dst.Height / (dst.Width / webBmp.Width)
src.Y = Convert.ToInt32((webBmp.Height - h) / 2)
@jz5
jz5 / gist:7871405
Created December 9, 2013 12:16
CodeBehind -> CodeFile
<%@ Page Language="vb" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="GeneratorWebForm" %>
@jz5
jz5 / gist:7871437
Created December 9, 2013 12:19
QueryString
Dim q = Context.Request.QueryString.Get("q")
If Not Uri.IsWellFormedUriString(q, UriKind.Absolute) Then
Exit Sub
End If
Dim url = New Uri(q)
.panel {
background: url('http://pronama.azurewebsites.net/chrome/sd_eye0.png') no-repeat;
background-size: contain;
background-position: 10px -5px;
}
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
AddType image/svg+xml svg