Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 03:16:23 +0000



Post From: Displaying an image on a trading chart

[2019-12-14 05:26:51]
Tony - Posts: 459
I managed to get around this with 'Stationary Text', to handle simple
images like a company logo or a pencil sketch, attached a screen shot of
a Apple logo, Peter Steidlmayer and a picture of my dog in "Stationary.png"

1, use an online ASCII art program like 'Glass Giant' to
convert your image into text.
2, paste text into 'Stationary Text', choose a font
that all letters have equal width, and set size to 1.
3, pick up what ever colour you like. (the Apple logo
consists 6 pieces of 'Stationary Text' on top of another)

You don't want your picture be too big, because maximum lines
'Stationary Text' can display is 125, (125 vertical 'pixels')
Human faces could be a bit tricky, you will have to convert
the image to pencil sketch style first, by using a image
processing program like GIMP, so it would have a realistic
looking.

For larger images, as the example shows in Image.png, size of 400x500 pixels,
you need a custom study to display text file by compiling following code, change
the font name (Noto Mono), folder location and size of text file (320K) if necessary:


//code start
#include "sierrachart.h"
SCDLLName("ImageToText")
SCSFExport scsf_ASCII_Art(SCStudyInterfaceRef canvas)
{
  SCInputRef HorizonPos = canvas.Input[0];
  SCInputRef VerticalPos = canvas.Input[1];
  SCInputRef TextColor = canvas.Input[2];
  SCInputRef FilePath = canvas.Input[3];
  
  if (canvas.SetDefaults) {
    canvas.GraphName = "ASCII Art";
    canvas.GraphRegion = 0;
    HorizonPos.Name = "Horizontal Position";
    HorizonPos.SetInt(12);
    VerticalPos.Name = "Vertical Position";
    VerticalPos.SetInt(98);
    TextColor.Name = "Text Color";
    TextColor.SetColor(0, 0, 0);
    FilePath.Name = "ASCII Text File";
    FilePath.SetPathAndFileName("C:\\SierraChart\\ASCII\\");
    return;
  }
  
  if (!canvas.HideStudy && !canvas.Index) {
    char TextPixels[320000] = {};
    int FileHandle = 1;
    unsigned int *p_BytesRead = new unsigned int(0);
    canvas.OpenFile(FilePath.GetPathAndFileName(), 2, FileHandle); //Open Mode: 2 (open for read only),
    canvas.ReadFile(FileHandle, TextPixels, 320000, p_BytesRead);
    canvas.CloseFile(FileHandle);

    s_UseTool Pencil;
    Pencil.Clear();
    Pencil.DrawingType = DRAWING_TEXT;
    Pencil.LineNumber = 2; //has to be greater than 0, set 0 will cause repetitive drawing
    Pencil.UseRelativeVerticalValues = 1;
    Pencil.BeginDateTime = HorizonPos.GetInt();
    Pencil.BeginValue = VerticalPos.GetInt();
    Pencil.AddMethod = UTAM_ADD_ALWAYS;
    Pencil.Color = TextColor.GetColor();
    Pencil.FontSize = 1;
    Pencil.Text = TextPixels;
    Pencil.FontFace = "Noto Mono";
    canvas.UseTool(Pencil);
  }
}
//code end
Date Time Of Last Edit: 2020-06-11 05:10:13
imageStationary.png / V - Attached On 2019-12-21 06:32:05 UTC - Size: 58.18 KB - 570 views
imageImage.png / V - Attached On 2020-02-20 06:02:51 UTC - Size: 265.66 KB - 606 views