Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:11:37+00:00 2026-05-25T13:11:37+00:00

I am trying to tile an image(16×16) over a Rectangle area of dimensions width=1000,

  • 0

I am trying to tile an image(16×16) over a Rectangle area of dimensions width=1000, height=16 using TextureBrush to get a strip like UI.

 Rectangle myIconDrawingRectangle = new Rectangle(x, y, 1000, 16);
 using (TextureBrush brush = new TextureBrush(myIcon, WrapMode.Tile))
 {
    e.Graphics.FillRectangle(brush, myIconDrawingRectangle );
 }

When I draw with x=0, y=0 tiling happens as expected starting from (0,0).

When I draw with x=0, y=50 tiling starts at (0,50) but the the painting rectangle does not start with the start of the image. It starts with cropped portion of the image and then repeats.

How to solve this?

P.S: I do not want to tile it manually looping repeatedly over DrawImage.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:11:37+00:00Added an answer on May 25, 2026 at 1:11 pm

    To ensure that start of the rectangle starts with start of the image we have use transforms as shown in below code.

    Rectangle myIconDrawingRectangle = new Rectangle(x, y, 1000, 16);
    using (TextureBrush brush = new TextureBrush(myIcon, WrapMode.Tile))
    {
        brush.TranslateTransform(x,y);
        e.Graphics.FillRectangle(brush, myIconDrawingRectangle);
    }
    

    I found this link helpful. This explains about brushes and transforms in detail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get an image on the background to tile until the
I'm trying to get the image SRC using this: var SRCNow = $('#'+ID+'.item').attr(src); on
I am trying to implement a lighting effect in an HTML5/JavaScript game using tile
I'm trying to get twitter update_profile_image to work using OAuth. I was using curl
I am adding an image into a JLabel and trying to set the width
I'm trying to get a bitmap to tile something like this: ---- ---- ----
I'm trying to get an image from an URL but when I save it
I'm developing a script to download images from tile-based image-hosting. I downloaded tiles using
I'm trying to tile an image or background image in a table cell in
So I have a tile image tile.png and I'm trying to create a tiled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.