Bild -> Comic Konverter von CodeMaster |
Hi, Leute. Bin gerade an einem *geheimen* Projekt. Dabei will ich ein Tool schreiben, welches ganz normale digitale Bilder in Comis konvertieren soll. Und das ist gar nicht so einfach!!! - Das durfte ich gerade feststellen. Vielleicht könnt ihr mir ja Tips zur Verbesserung geben, wenn ihr euch meinen kleinen ersten Ansatz anseht: [code:1:f13864fd1a]Dim Gray(400,400) Graphics 800,600 SetBuffer BackBuffer() image = CreateComic("test.bmp") Function CreateComic(Bmp$) Bmp = LoadImage(Bmp$) MaskImage Bmp,255,0,255 Buffer = GraphicsBuffer() Width = ImageWidth(Bmp) Height = ImageHeight(Bmp) aliasing = 15 SetBuffer FrontBuffer() Color 255,0,255 Rect 0,0,GraphicsWidth(),GraphicsHeight(),1 DrawImage Bmp,0,0 LockBuffer() For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF Gray(x,y) = (R + G + B) / 3 If (Not R = 255) And (Not G = 0) And (Not B = 255) Then R = Int(R / 64) * 64 * 1.2 G = Int(G / 64) * 64 * 1.2 B = Int(B / 64) * 64 * 1.2 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then For w = 1 To 5 For i = 0 To 360 Step 5 tx = x + Cos(i) * w ty = y + Sin(i) * w If (tx > 0) And (ty > 0) And (tx < Width) And (ty < Height) Then RGB2 = ReadPixelFast(tx,ty) Rt = (RGB2 And $FF0000) / $10000 Gt = (RGB2 And $FF00) / $100 Bt = RGB2 And $FF If (Not Rt = 255) And (Not Gt = 0) And (Not Bt = 255) Then R = R * w/5 + Rt * (5-w)/5 G = G * w/5 + Gt * (5-w)/5 B = B * w/5 + Bt * (5-w)/5 EndIf EndIf Next Next R = R * 1.15 G = G * 1.15 B = B * 1.15 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf If KeyDown(1) Then End EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then Gr# = (Int(Gray(x,y)/20)*20)*10000/255;If Gray(x,y) < 50 Then R = 0 G = 0 B = 0 R = R * Gr#/10000*1.8 G = G * Gr#/10000*1.8 B = B * Gr#/10000*1.8 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then For w = 1 To 3 For i = 0 To 360 Step 5 tx = x + Cos(i) * w ty = y + Sin(i) * w If (tx > 0) And (ty > 0) And (tx < Width) And (ty < Height) Then RGB2 = ReadPixelFast(tx,ty) Rt = (RGB2 And $FF0000) / $10000 Gt = (RGB2 And $FF00) / $100 Bt = RGB2 And $FF If (Not Rt = 255) And (Not Gt = 0) And (Not Bt = 255) Then R = R * w/3 + Rt * (3-w)/3 G = G * w/3 + Gt * (3-w)/3 B = B * w/3 + Bt * (3-w)/3 EndIf EndIf Next Next R = R * 1.15 G = G * 1.15 B = B * 1.15 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf If KeyDown(1) Then End EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then R = Int(R / 104) * 104 * 1.2 G = Int(G / 104) * 104 * 1.2 B = Int(B / 104) * 104 * 1.2 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then For w = 1 To 8 For i = 0 To 360 Step 5 tx = x + Cos(i) * w ty = y + Sin(i) * w If (tx > 0) And (ty > 0) And (tx < Width) And (ty < Height) Then RGB2 = ReadPixelFast(tx,ty) Rt = (RGB2 And $FF0000) / $10000 Gt = (RGB2 And $FF00) / $100 Bt = RGB2 And $FF If (Not Rt = 255) And (Not Gt = 0) And (Not Bt = 255) Then R = R * w/8 + Rt * (8-w)/8 G = G * w/8 + Gt * (8-w)/8 B = B * w/8 + Bt * (8-w)/8 EndIf EndIf Next Next R = R * 1.15 G = G * 1.15 B = B * 1.15 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf If KeyDown(1) Then End EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then R = Int(R / 104) * 104 * 1.2 G = Int(G / 104) * 104 * 1.2 B = Int(B / 104) * 104 * 1.2 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then For w = 1 To 8 For i = 0 To 360 Step 5 tx = x + Cos(i) * w ty = y + Sin(i) * w If (tx > 0) And (ty > 0) And (tx < Width) And (ty < Height) Then RGB2 = ReadPixelFast(tx,ty) Rt = (RGB2 And $FF0000) / $10000 Gt = (RGB2 And $FF00) / $100 Bt = RGB2 And $FF If (Not Rt = 255) And (Not Gt = 0) And (Not Bt = 255) Then R = R * w/8 + Rt * (8-w)/8 G = G * w/8 + Gt * (8-w)/8 B = B * w/8 + Bt * (8-w)/8 EndIf EndIf Next Next R = R * 1.15 G = G * 1.15 B = B * 1.15 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf If KeyDown(1) Then End EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then R = Int(R / 84) * 84 * 1.2 G = Int(G / 84) * 84 * 1.2 B = Int(B / 84) * 84 * 1.2 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then Gr# = (Int(Gray(x,y)/20)*20)*10000/255;If Gray(x,y) < 50 Then R = 0 G = 0 B = 0 R = R * Gr#/10000*1.8 G = G * Gr#/10000*1.8 B = B * Gr#/10000*1.8 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf EndIf Next Next For y = 0 To Height For x = 0 To Width If (x > 0) And (y > 0) And (x < GraphicsWidth()) And (y < GraphicsHeight()) Then RGB = ReadPixelFast(x,y) R = (RGB And $FF0000) / $10000 G = (RGB And $FF00) / $100 B = RGB And $FF If (Not R = 255) And (Not G = 0) And (Not B = 255) Then For w = 1 To 4 For i = 0 To 360 Step 5 tx = x + Cos(i) * w ty = y + Sin(i) * w If (tx > 0) And (ty > 0) And (tx < Width) And (ty < Height) Then RGB2 = ReadPixelFast(tx,ty) Rt = (RGB2 And $FF0000) / $10000 Gt = (RGB2 And $FF00) / $100 Bt = RGB2 And $FF If (Not Rt = 255) And (Not Gt = 0) And (Not Bt = 255) Then R = R * w/4 + Rt * (4-w)/4 G = G * w/4 + Gt * (4-w)/4 B = B * w/4 + Bt * (4-w)/4 EndIf EndIf Next Next R = R * 1.15 G = G * 1.15 B = B * 1.15 If R < 0 Then R = 0 If G < 0 Then G = 0 If B < 0 Then B = 0 If R > 255 Then R = 255 If G > 255 Then G = 255 If B > 255 Then B = 255 Mix = R * $10000 + G * $100 + B WritePixelFast x,y,Mix EndIf If KeyDown(1) Then End EndIf Next Next UnlockBuffer() WaitKey() End Function End[/code:1:f13864fd1a] Alles, was ihr braucht, ist ein Bild namens "Test.bmp", welches maximal 400x400 Pixel groß sein darf und vorzugsweise eine Nahaufname eines Gesichts mit vielen Kontrasten sein sollte. Setzt euch einfach mal zurück und wartet ab, was passiert mit dem Bild. Es sieht vielleicht nicht gerade aus wie ein Comic, aber ich habe ganz nützliche Features im Code wie z.B. Unsharpening, Antialiasing, Colorkompressing etc... |
von ??? |
Comic? Hmmm... Als das Prog mit meinem Bild fertig war sah es aus wie gerade in den Hexler gefallen. *g* Sorry, ist aber so. Trotzdem net anzusehen was da alles mit dem armen Bild gemacht wird. |
von ??? |
interessant was du alles mit dem Bild machst, sieht allerdings nicht wirklich Comix mäßig aus. Meiner meinung nach, sieht es nach den ersten Paar schritten sogar noch am besten aus :) |
von ??? |
Tja, das ist das Problem - woher soll der PC wissen, dass das z.B ein Gesicht ist - und vorallem woher soll er wissen, was was vom Gesicht ist :) Trotzdem wie gesagt ganz gut. Besonders die Kantenglättung *g* :o |
von ??? |
ich würde nach starken kontrasten suchen und dort schwarze striche ziehen... ( wenn jetzt aber jemand mit ner roten hose vor nem roten haus steht hat man ein problem....) dann würde ich die farbanzahl einfach evrringern.... die formen würde ich nicht verändern, da das doch etwas ins auge gehen könnte ;) |