Author Topic: TempGraphic  (Read 12212 times)

Offline Wipe

  • Rotator
  • Random is god
TempGraphic
« on: November 12, 2012, 05:03:17 am »
Silly result of even more silly bet; i was supposed to create graphics for 20 inventory items in less than hour, so i did it like a typical slacker. Program name speaks for itself, don't expect much... ;)

http://rotators.fodev.net/wipe/TempGraphic.zip
https://github.com/rotators/fo2238/tree/master/Tools/TempGraphic/

I'll be amazed if anyone will find it useful
« Last Edit: August 08, 2013, 11:59:41 am by Wipe »
Games are meant to be created, not played...

JovankaB

  • Guest
Re: TempGraphic
« Reply #1 on: November 12, 2012, 08:17:28 am »
Very nice! I used it to create avatar.
Interface is intuitive, I found no bugs. I recommend it to everyone.
« Last Edit: November 12, 2012, 08:27:18 am by JovankaB »

Re: TempGraphic
« Reply #2 on: November 12, 2012, 09:49:32 am »
Isn't Jovanka amazing?  :-*

Offline Gob

  • The Good
Re: TempGraphic
« Reply #3 on: November 14, 2012, 01:21:51 pm »
I converted your program to VB.NET, here is the code. I hope you don't mind.

Code: [Select]
Imports System
Imports System.Drawing
Imports System.Data
Imports System.Deployment
Imports System.Drawing.Imaging
Imports System.Windows.Forms
Namespace TempGraphic

End Namespace

Partial Public Class frmMain
    Inherits Form

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.CreateImage("")
    End Sub

    Private Sub CreateImage(ByVal text As String)
        Dim lines() As String = text.Split(New String() {"" & vbCrLf}, StringSplitOptions.RemoveEmptyEntries)
        If ((lines.Length > 0) _
                    AndAlso (lines.Length < 4)) Then
            Dim font As Font = New Font("Tahoma", 8, FontStyle.Bold)
            Dim bmp As Bitmap = New Bitmap(1, 1)
            Dim w As Integer = 0
            Dim g As Graphics = Graphics.FromImage(bmp)
            For Each line As String In lines
                Dim tmpsize As SizeF = g.MeasureString(line, font, 90)
                If (tmpsize.Width > w) Then
                    w = CType(tmpsize.Width, Integer)
                End If
            Next
            bmp = New Bitmap((w + 10), (25 _
                            + ((lines.Length - 1) _
                            * (lines.Length > 1))))
            Dim x As Integer = 1
            Do While (x < bmp.Width)
                Dim y As Integer = 1
                Do While (y < bmp.Height)
                    If (((x = 1) _
                                OrElse (y = 1)) _
                                OrElse ((x _
                                = (bmp.Width - 1)) _
                                OrElse (y _
                                = (bmp.Height - 1)))) Then
                        bmp.SetPixel(x, y, Color.White)
                    Else
                        bmp.SetPixel(x, y, Color.FromArgb(104, 36, 96))
                    End If
                    y = (y + 1)
                Loop
                x = (x + 1)
            Loop
            Dim l As Integer = 0
            For Each line As String In lines
                g.DrawString(line, font, Brushes.White, 5, (5 _
                                + (l * 15)))
                l = (l + 1)
            Next
            Me.pictureBox1.Image = CType(bmp, Image)
            Me.button1.Enabled = True
        Else
            Me.pictureBox1.Image = Nothing
            Me.button1.Enabled = False
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        If Me.pictureBox1 IsNot Nothing Then
            Dim result As DialogResult = Me.saveFileDialog1.ShowDialog()

            If result = DialogResult.OK Then
                Me.pictureBox1.Image.Save(Me.saveFileDialog1.FileName, ImageFormat.Png)
            End If
        End If
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textBox1.TextChanged
        Dim self As TextBox = DirectCast(sender, TextBox)

        Me.CreateImage(self.Text)
    End Sub
End Class

The only thing I wasn't able to do is make the text show in the picture.
« Last Edit: November 14, 2012, 01:24:33 pm by Gob »

Re: TempGraphic
« Reply #4 on: August 06, 2013, 04:05:22 am »
Link is dead  :-\

Offline Ganado

  • Moderator
  • Dishonest Abe
Re: TempGraphic
« Reply #5 on: August 06, 2013, 04:32:46 am »
You're right, it was never re-uploaded after move. Until it's re-uploaded, here's a temporary link to the .zip file: http://www.sendspace.com/file/tnmb62 (Don't accidentally download one of those ads).
« Last Edit: August 06, 2013, 04:35:58 am by Ganado »
Error while opening cfg file: spawnnpc.cfg
Shit! Damn admins! Always ruining my fun! I guess I'll talk to them. WITH MY FISTS!!!! No seriously, I will write them a nice email or make a thread on the forums or something. Thanks!

Re: TempGraphic
« Reply #6 on: August 06, 2013, 04:43:08 am »
You're right, it was never re-uploaded after move. Until it's re-uploaded, here's a temporary link to the .zip file: http://www.sendspace.com/file/tnmb62 (Don't accidentally download one of those ads).
Thanks Ganado !

Offline Wipe

  • Rotator
  • Random is god
Re: TempGraphic
« Reply #7 on: August 08, 2013, 12:00:28 pm »
Totally forgot about this one ;D
Anyway, re-uploaded and updated links.
Games are meant to be created, not played...