labs.insert-title.com

Dynamic Color Shifting

The Code: colorshift.aspx

	
<%@ Page Explicit="True" Language="VB" Debug="True" %> 
<%@ import namespace="system.drawing" %>
<%@ import namespace="system.drawing.imaging" %>
<%@ Import Namespace="system.io" %>
<script runat="server">
Dim Filename
dim Img as System.Drawing.Bitmap
dim x,y,h,w,l,s as Integer
sub CreateGraphic()
	Filename = Request.QueryString("filename")
	Filename = server.mappath(Filename)
	Img = system.drawing.bitmap.FromFile(Filename)
	s = Request.QueryString("s")
	h = Img.height
	w = Img.width
	for y = 1 to h-1
		for x = 1 to w-1
		Dim c as Color = Img.GetPixel(x,y)
		l = CInt(c.R*0.3 + c.G*0.59 + c.B*0.11)
			if s = 0 then		'0 = GRAYSCALE
				Img.SetPixel(x,y,Color.FromArgb(l,l,l))
			elseif s = 1 then	'1 = RED
				Img.SetPixel(x,y,Color.FromArgb(l,0,0))
			elseif s = 2 then	'2 = GREEN
				Img.SetPixel(x,y,Color.FromArgb(0,l,0))
			elseif s = 3 then	'3 = BLUE
				Img.SetPixel(x,y,Color.FromArgb(0,0,l))
			elseif s = 4 then	'4 = PURPLE
				Img.SetPixel(x,y,Color.FromArgb(l,0,l))
			elseif s = 5 then	'5 = YELLOW
				Img.SetPixel(x,y,Color.FromArgb(l,l,0))
			elseif s = 6 then	'6 = BLUE-GREEN
				Img.SetPixel(x,y,Color.FromArgb(0,l,L))
			end if
		next
		next
end sub
</script>
<%
CreateGraphic
Img.Save(Response.OutputStream, ImageFormat.JPEG)
Img.dispose()
response.end
%>



Usage


<img src="colorshift.aspx?filename=FILENAME.JPG&s=CHOOSE 0 THRU 6 SEE CODE" />
	

Example






Discussion

Rahul

Its good asp code nice script

Rahul

Its good asp code nice script

Web 2.0

Kewl effect.

AL badwawi

nice script..thanks

New comments are currently disabled, you can find me @joemaddalone Comments temporarily disabled for now, you can find me @joemaddalone