none
Fremy Extension Standard Graphics RRS feed

  • Question

  • The below program uses Fremy's extension.  I first establish an object area by using the operation "CreateGraphicsFromUI" which I think sets up an area of memory which is same as the GUI area.  I than use the standard graphics operation to draw a rectangle.  Then I use Fremy's extension to write some text and draw a ellipse.  All 3 items show in the graphics window when the program is ran.  Problem is that when I look at the file that was written it doesn't show the rectangle.  Any ideas as to why it doesn't show? 

    GraphicsWindow.Show()
    Window=FCDrawings.CreateGraphicsfromui()
    GraphicsWindow.Brushcolor="Blue"
    GraphicsWindow.DrawRectangle(100,100,100,100)
    FCDrawings.DrawText(Window"This is Text", 50, 50)
    FCDrawings.DrawEllipse(Window,"Green",3,50,50,100,100)
    Window1=FCDrawings.GenerateImage(Window)
    Shapes.AddImage(Window1)
    FCDrawings.SaveGraphicsToFile(Window,"c:\temp\testing.png")
    'Printing.PrintFile("c:\temp\testing.png"," ")

    Jricestk

     

    Saturday, August 7, 2010 11:20 PM
    Answerer

Answers

  • Looking at the FC extension code it looks like CreateGraphicsFromUI is creating a new object similar to GraphicsWindow (i.e. it is a similar object sharing some features with additional functionality, not extended functionality embedded within the default GraphicsWindow object).

    The description states:

    "Create a graphical representation of your GraphicsWindow object, on which you can perform operations" which pretty much describes this.

    Sunday, August 8, 2010 7:22 PM
    Moderator

All replies

  • Try:

    FCDrawings.DrawRectangle(Window,"Blue",2,100,100,100,100)

     

    Saturday, August 7, 2010 11:30 PM
    Moderator
  • Litdev,

    I know that what you suggested will work OK.  I am trying to understand why the standard graphics functions won't get copied into the file.  They do show on the graphics screen, but none of them will copy to the file.  Any idea why?

    Thanks,

    Jricestk

     

    Sunday, August 8, 2010 1:58 AM
    Answerer
  • The extension has additional functionality to the standard GraphicsWidow comands (i.e. the extension can write to an image file as well as the window, while the standard SmallBasic commands only display to the GraphicsWIndow).  To use the extended capability, you need to use its methods present in FCDrawings.
    Sunday, August 8, 2010 10:13 AM
    Moderator
  • Litdev,

    I know that what you suggested will work OK.  I am trying to understand why the standard graphics functions won't get copied into the file.  They do show on the graphics screen, but none of them will copy to the file.  Any idea why?

    Thanks,

    Jricestk

     

    Hey there!

    Without seeing the source code, I can't say for certain, but most likely reason is that Fremy's extension can only see the objects that fremy's extension draws. Thanks to the principles of Object Oriented Programing, the items that you draw with the GraphicsWindow object are stored in GraphicsWindow. The items that you draw with FCDrawings are stored in FCDrawings. FCDrawings can't actually see the data inside of GraphicsWindow and vice versa. Thus, FCDrawings can't save stuff that GraphicsWindows draws. There are ways around that, but its a pain to circumvent. (Beleive me, I know) 

    Sunday, August 8, 2010 1:42 PM
  • WriterCoder,

    I think what is interesting about this is that I used the command "Window=FCDrawings.CreateGraphicsFromUi()".  I would have thought that this command would use the same area of memory as the UI.  So, I don't see any difference in using this command than "FCDrawings.CreateGraphics().  Seems like both commands do the exact same thing.

    Jricestk

    Sunday, August 8, 2010 2:26 PM
    Answerer
  • WriterCoder,

    I think what is interesting about this is that I used the command "Window=FCDrawings.CreateGraphicsFromUi()".  I would have thought that this command would use the same area of memory as the UI.  So, I don't see any difference in using this command than "FCDrawings.CreateGraphics().  Seems like both commands do the exact same thing.

    Jricestk

    Did some reading of the help file. CreateGraphicsFromUi() I beleive loads the graphics from the GraphicsWindow into FCDrawings. CreateGraphics loads the graphics from ImageList. Try using this code and see what happens:

    GraphicsWindow.Show()
    GraphicsWindow.Brushcolor="Blue"
    GraphicsWindow.DrawRectangle(100,100,100,100)

    GraphicsImage1 =FCDrawings.CreateGraphicsfromui()

    FCDrawings.DrawText(GraphicsImage1, "This is Text", 50, 50)
    FCDrawings.DrawEllipse(GraphicsImage1,"Green",3,50,50,100,100)
    Window1=FCDrawings.GenerateImage(GraphicsImage1)
    Shapes.AddImage(Window1)
    FCDrawings.SaveGraphicsToFile(GraphicsImage1, "c:\temp\testing.png")
    'Printing.PrintFile("c:\temp\testing.png"," ")

    Sunday, August 8, 2010 5:00 PM
  • jricestk ,

    Is idea of this to get content of GraphicsWindow to png file?

    I am planning to make own Graphics tools and add functions like TakeScreenShot(X,Y,Widht,Height) and SetHue(Image, NewHue) and resize(Image,Widht,Height) and crop(LeftMargin,TopMargin,RightMargin,BottomMargin) and ConvertToBlackAndWhite(Image).

    Also I can do Printing.PrintDocument, It is like Fremys Graphics with better quality and it have more shapes but it will have one bug : you cant remove any shapes from that.


    Also you have bug in you code = 'Printing.PrintFile("c:\temp\testing.png"," ")

    You must always give PrintFont or Printing fails.


    Sorry My Bad English
    Sunday, August 8, 2010 5:17 PM
  • WriterCoder,

    I tried your code idea which I would think would work, but it didn't.  It still doesn't put the rectangle in the file.  So, it would seem like the command "FCDrawings.CreateGraphicsFromUI" doesn't do what I think it should do.

    Thanks for the try,

    Jricestk

    Sunday, August 8, 2010 6:46 PM
    Answerer
  • Oskariok,

    I think that your idea on being able to print on paper a screen shot of the graphics window would be great!  One of my programs creates graphics that I can get on the screen, but I would like to be able to take it to paper.

    Thanks,

    Jricestk

    Sunday, August 8, 2010 6:51 PM
    Answerer
  • Looking at the FC extension code it looks like CreateGraphicsFromUI is creating a new object similar to GraphicsWindow (i.e. it is a similar object sharing some features with additional functionality, not extended functionality embedded within the default GraphicsWindow object).

    The description states:

    "Create a graphical representation of your GraphicsWindow object, on which you can perform operations" which pretty much describes this.

    Sunday, August 8, 2010 7:22 PM
    Moderator
  • WriterCoder,

    I tried your code idea which I would think would work, but it didn't.  It still doesn't put the rectangle in the file.  So, it would seem like the command "FCDrawings.CreateGraphicsFromUI" doesn't do what I think it should do.

    Thanks for the try,

    Jricestk

    Ok, I think I understand it... The CreateGraphicsFromUI doesn't access the Graphicswindow's graphics. It creates an Graphics object in memory with the same dimensions as the GraphicsWindow's veiw pane. So if you did:

    FCDrawings.CreateGraphicsFromUI()

    its the same as

    FCDrawings.CreateGraphics(GraphicsWindow.Width, GraphicsWindow.Height)

    Looks like litdev may have hit the nail on the head.

    Monday, August 9, 2010 1:28 AM
  • WriterCoder and LitDev,

    Besides picking up the size of the graphics window if the Pen Color in the regular graphics window is set it will use that color in Fremy's extension to draw the text.  I marked Fremy's reply as the answer.

    Thanks to all,

    Jricestk 

    Monday, August 9, 2010 1:28 PM
    Answerer